id
stringlengths 14
16
| text
stringlengths 1
2.43k
| source
stringlengths 99
229
|
|---|---|---|
174e9fef6018-2
|
Use the following command to import an image with an encrypted root volume\.
```
aws ec2 import-image --description "My server disks" --encrypted --kms-key-id 0ea3fef3-80a7-4778-9d8c-1c0c6EXAMPLE --disk-containers "file://C:\import\containers.json"
```
The CMK provided for encryption must not be disabled during the entire import process\. For more information, see [Amazon EBS Encryption](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html) in the *Amazon EC2 User Guide*\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmimport-image-import.md
|
1eda9c7c47ae-0
|
Use the [describe\-import\-image\-tasks](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-import-image-tasks.html) command to return the status of an import task\.
```
aws ec2 describe-import-image-tasks --import-task-ids import-ami-1234567890abcdef0
```
Status values include the following:
+ `active` β The import task is in progress\.
+ `deleting` β The import task is being canceled\.
+ `deleted` β The import task is canceled\.
+ `updating` β Import status is updating\.
+ `validating` β The imported image is being validated\.
+ `validated` β The imported image was validated\.
+ `converting` β The imported image is being converted into an AMI\.
+ `completed` β The import task is completed and the AMI is ready to use\.
After the import image task is completed, the output includes the ID of the AMI\. The following is example output that includes `ImageId`\.
```
{
"ImportImageTasks": [
{
"ImportTaskId": "import-ami-01234567890abcdef",
"ImageId": "ami-1234567890EXAMPLE",
"SnapshotDetails": [
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmimport-image-import.md
|
1eda9c7c47ae-1
|
"ImageId": "ami-1234567890EXAMPLE",
"SnapshotDetails": [
{
"DiskImageSize": 705638400.0,
"Format": "ova",
"SnapshotId": "snap-111222333444aaabb"
"Status": "completed",
"UserBucket": {
"S3Bucket": "my-import-bucket",
"S3Key": "vms/my-server-vm.ova"
}
}
],
"Status": "completed"
}
]
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmimport-image-import.md
|
288bf89fec10-0
|
If you need to cancel an active import task, use the [cancel\-import\-task](https://docs.aws.amazon.com/cli/latest/reference/ec2/cancel-import-task.html) command\.
```
aws ec2 cancel-import-task --import-task-id import-ami-1234567890abcdef0
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmimport-image-import.md
|
9e2f4cfe20ad-0
|
After the import image task is complete, you can launch an instance using the resulting AMI or copy the AMI to another Region\.
**Windows**
+ [Launching an Instance](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/launching-instance.html)
+ [Copying an AMI](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/CopyingAMIs.html)
**Linux**
+ [Launching an Instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/launching-instance.html)
+ [Copying an AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/CopyingAMIs.html)
For some operating systems, the device drivers for enhanced networking and NVMe block devices that are required by [Nitro\-based instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html#ec2-nitro-instances) are not installed automatically during import\. To install these drivers manually, use the directions in the following documentation\. Next, create a new AMI from the customized instance\.
**Windows**
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmimport-image-import.md
|
9e2f4cfe20ad-1
|
**Windows**
+ \(Recommended\) [Installing the Latest Version of EC2Config](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/UsingConfig_Install.html) or [Installing the Latest Version of EC2Launch](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch-download.html)
+ [Enabling Enhanced Networking on Windows Instances](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html)
+ [AWS NVMe Drivers for Windows Instances](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html)
**Linux**
+ [Enabling Enhanced Networking on Linux Instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking-ena.html)
+ [Install or Upgrade the NVMe Driver](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html#install-nvme-driver)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmimport-image-import.md
|
1a044d8e5bef-0
|
-----
*****Copyright © 2020 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.*****
-----
Amazon's trademarks and trade dress may not be used in
connection with any product or service that is not Amazon's,
in any manner that is likely to cause confusion among customers,
or in any manner that disparages or discredits Amazon. All other
trademarks not owned by Amazon are the property of their respective
owners, who may or may not be affiliated with, connected to, or
sponsored by Amazon.
-----
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/index.md
|
ab0b5608e5d9-0
|
+ [What Is VM Import/Export?](what-is-vmimport.md)
+ [How VM Import/Export Works](how-vm-import-export-works.md)
+ [VM Import/Export Requirements](vmie_prereqs.md)
+ [Importing a VM as an Image Using VM Import/Export](vmimport-image-import.md)
+ [Importing a VM as an Instance Using VM Import/Export](vmimport-instance-import.md)
+ [Importing a Disk as a Snapshot Using VM Import/Export](vmimport-import-snapshot.md)
+ [Exporting an Instance as a VM Using VM Import/Export](vmexport.md)
+ [Exporting a VM Directly from an Amazon Machine Image (AMI)](vmexport_image.md)
+ [Security in VM Import/Export](security.md)
+ [Data Protection in VM Import/Export](data-protection.md)
+ [Compliance Validation for VM Import/Export](compliance-validation.md)
+ [Resilience in VM Import/Export](disaster-recovery-resiliency.md)
+ [Infrastructure Security in VM Import/Export](infrastructure-security.md)
+ [Troubleshooting VM Import/Export](vmimport-troubleshooting.md)
+ [Document History for VM Import/Export](doc-history.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/index.md
|
c8668347ac3a-0
|
Cloud security at AWS is the highest priority\. As an AWS customer, you benefit from a data center and network architecture that is built to meet the requirements of the most security\-sensitive organizations\.
Security is a shared responsibility between AWS and you\. The [shared responsibility model](http://aws.amazon.com/compliance/shared-responsibility-model/) describes this as security of the cloud and security in the cloud:
+ **Security of the cloud** β AWS is responsible for protecting the infrastructure that runs AWS services in the AWS Cloud\. AWS also provides you with services that you can use securely\. Third\-party auditors regularly test and verify the effectiveness of our security as part of the [AWS Compliance Programs](http://aws.amazon.com/compliance/programs/)\. To learn about the compliance programs that apply to VM Import/Export, see [AWS Services in Scope by Compliance Program](http://aws.amazon.com/compliance/services-in-scope/)\.
+ **Security in the cloud** β Your responsibility is determined by the AWS service that you use\. You are also responsible for other factors including the sensitivity of your data, your companyβs requirements, and applicable laws and regulations
This documentation helps you understand how to apply the shared responsibility model when using VM Import/Export\. It shows you how to configure VM Import/Export to meet your security and compliance objectives\. You also learn how to use other AWS services that help you to monitor and secure your VM Import/Export resources\.
**Topics**
+ [Data Protection in VM Import/Export](data-protection.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/security.md
|
c8668347ac3a-1
|
**Topics**
+ [Data Protection in VM Import/Export](data-protection.md)
+ [Compliance Validation for VM Import/Export](compliance-validation.md)
+ [Resilience in VM Import/Export](disaster-recovery-resiliency.md)
+ [Infrastructure Security in VM Import/Export](infrastructure-security.md)
For more information about security and EC2 instances, Amazon Machine Images \(AMI\), and EBS volumes, see [Security in Amazon EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security.html) in the *Amazon EC2 User Guide*\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/security.md
|
5f098454eeb9-0
|
Exporting a VM file based on an Amazon Machine Image \(AMI\) is useful when you want to deploy a new, standardized instance in your on\-site virtualization environment\. You can export most AMIs to Citrix Xen, Microsoft Hyper\-V, or VMware vSphere\.
When you export an image, you are charged the standard Amazon S3 rates for the bucket where the exported VM is stored\. In addition, there might be a small charge for the temporary use of an Amazon EBS snapshot\. For more information about Amazon S3 pricing, see [Amazon Simple Storage Service Pricing](https://aws.amazon.com/s3/pricing/)\.
**Topics**
+ [Prerequisites](#vmexport-prerequisites)
+ [Considerations for Image Export](#vmexport-limits)
+ [Start an Export Image Task](#start-image-export)
+ [Monitor an Export Image Task](#monitor-image-export)
+ [Cancel an Export Image Task](#cancel-image-export)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmexport_image.md
|
59959a7f1490-0
|
To export a VM from Amazon EC2, first meet the following prerequisites\.
+ Install the AWS CLI\. For more information, see the [AWS Command Line Interface User Guide](https://docs.aws.amazon.com/cli/latest/userguide/)\.
+ Create an Amazon S3 bucket for storing the exported images or choose an existing bucket\. The bucket must be in the Region where you want to export your VMs\. For more information about S3 buckets, see the [Amazon Simple Storage Service Console User Guide](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/)\.
+ Create an IAM role named `vmimport`\. For more information, see [Required Service Role](vmie_prereqs.md#vmimport-role)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmexport_image.md
|
084957cdf001-0
|
Exporting images and volumes is subject to the following limitations:
+ You must export to one of the following image formats that your virtualization environment supports:
+ Virtual Hard Disk \(VHD\), which is compatible with Citrix Xen and Microsoft Hyper\-V virtualization products\.
+ Stream\-optimized ESX Virtual Machine Disk \(VMDK\), which is compatible with VMware ESX and VMware vSphere versions 4, 5, and 6\.
+ Raw format\.
To convert exported VMDK files to OVF, use the [VMware OVF Tool](https://www.vmware.com/support/developer/ovf/)\.
+ You can't export an image if it contains third\-party software provided by AWS\. For example, VM Export cannot export Windows or SQL Server images, or any image created from an image in the AWS Marketplace\.
+ You can't export an image with encrypted EBS snapshots in the block device mapping\.
+ You can only export EBS data volumes that are specified in the block device mapping, not EBS volumes attached after instance launch\.
+ You can't export an image from Amazon EC2 if you've shared it from another AWS account\.
+ You can't have multiple export image tasks in progress for the same AMI at the same time\.
+ You can't have more than 20 conversion tasks per Region in progress at the same time\.
+ VMs with volumes larger than 1 TiB are not supported\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmexport_image.md
|
084957cdf001-1
|
+ VMs with volumes larger than 1 TiB are not supported\.
+ You can export a volume to either an unencrypted Amazon S3 bucket or to a bucket encrypted using AWS\-256 encryption\. You cannot export to an S3 bucket encrypted using AWS\-KMS encryption\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmexport_image.md
|
6b45e030adfe-0
|
To export your image, use the [export\-image](https://docs.aws.amazon.com/cli/latest/reference/ec2/export-image.html) command\. The exported file is written to the specified S3 bucket using the following S3 key: *prefix*export\-ami\-*id*\.*format* \(for example, my\-export\-bucket/exports/export\-ami\-1234567890abcdef0\.ova\)\.
```
aws ec2 export-image --image-id ami-id --disk-image-format VMDK --s3-export-location S3Bucket=my-export-bucket,S3Prefix=exports/
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmexport_image.md
|
10d87f85de80-0
|
To monitor the export of your image, use the following [describe\-export\-image\-tasks](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-export-image-tasks.html) command:
```
aws ec2 describe-export-image-tasks --export-image-task-ids export-ami-1234567890abcdef0
```
The following is an example response\. The status shown is `active`, which means that the export task is in progress\. The image is ready to use when the status is `completed`\.
```
{
"ExportImageTasks": [
{
"ExportImageTaskId": "export-ami-1234567890abcdef0"
"Progress": "21",
"S3ExportLocation": {
"S3Bucket": "my-export-bucket",
"S3Prefix": "exports/"
},
"Status": "active",
"StatusMessage": "updating"
}
]
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmexport_image.md
|
18e1ef0ee904-0
|
If you need to, you can use the following [cancel\-export\-task](https://docs.aws.amazon.com/cli/latest/reference/ec2/cancel-export-task.html) command to cancel the export of an image that is in progress\.
```
aws ec2 cancel-export-task --export-task-id export-ami-1234567890abcdef0
```
If the export task is complete or is in the process of transferring the final disk image, the command fails and returns an error\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/vm-import-export-user-guide/doc_source/vmexport_image.md
|
4cdebfa8efe8-0
|
Context values are key\-value pairs that can be associated with a stack or construct\. The AWS CDK uses context to cache information from your AWS account, such as the Availability Zones in your account or the Amazon Machine Image \(AMI\) IDs used to start your instances\. [Feature flags](featureflags.md) are also context values\. You can create your own context values for use by your apps or constructs\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
f6bb7b7ba217-0
|
Context values are made available to your AWS CDK app in six different ways:
+ Automatically from the current AWS account\.
+ Through the \-\-context option to the cdk command\.
+ In the project's `cdk.context.json` file\.
+ In the project's `cdk.json` file\.
+ In the `context` key of your `~/.cdk.json` file\.
+ In your AWS CDK app using the `construct.node.setContext` method\.
The project file `cdk.context.json` is where the AWS CDK caches context values retrieved from your AWS account\. This practice avoids unexpected changes to your deployments when, for example, a new Amazon Linux AMI is released, changing your Auto Scaling group\. The AWS CDK does not write context data to any of the other files listed\.
We recommend that your project's context files be placed under version control along with the rest of your application, as the information in them is part of your app's state and is critical to being able to synthesize and deploy consistently\.
Context values are scoped to the construct that created them; they are visible to child constructs, but not to siblings\. Context values set by the AWS CDK Toolkit \(the cdk command\), whether automatically, from a file, or from the \-\-context option, are implicitly set on the `App` construct, and so are visible to every construct in the app\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
f6bb7b7ba217-1
|
You can get a context value using the `construct.node.tryGetContext` method\. If the requested entry is not found on the current construct or any of its parents, the result is `undefined` \(or your language's equivalent, such as `None` in Python\)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
09bc2a54838f-0
|
The AWS CDK supports several context methods that enable AWS CDK apps to get contextual information\. For example, you can get a list of Availability Zones that are available in a given AWS account and AWS Region, using the [stack\.availabilityZones](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Stack.html#availabilityzones) method\.
The following are the context methods:
[HostedZone\.fromLookup](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-route53.HostedZone.html#static-from-wbr-lookupscope-id-query)
Gets the hosted zones in your account\.
[stack\.availabilityZones](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Stack.html#availabilityzones)
Gets the supported Availability Zones\.
[StringParameter\.valueFromLookup](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ssm.StringParameter.html#static-value-wbr-from-wbr-lookupscope-parametername)
Gets a value from the current Region's Amazon EC2 Systems Manager Parameter Store\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
09bc2a54838f-1
|
Gets a value from the current Region's Amazon EC2 Systems Manager Parameter Store\.
[Vpc\.fromLookup](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.Vpc.html#static-from-wbr-lookupscope-id-options)
Gets the existing Amazon Virtual Private Clouds in your accounts\.
[LookupMachineImage](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.LookupMachineImage.html)
Looks up a machine image for use with a NAT instance in an Amazon Virtual Private Cloud\.
If a given context information isn't available, the AWS CDK app notifies the AWS CDK CLI that the context information is missing\. The CLI then queries the current AWS account for the information, stores the resulting context information in the `cdk.context.json` file, and executes the AWS CDK app again with the context values\.
Don't forget to add the `cdk.context.json` file to your source control repository to ensure that subsequent synth commands will return the same result, and that your AWS account won't be needed when synthesizing from your build system\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
676ccf1ee29e-0
|
Use the cdk context command to view and manage the information in your `cdk.context.json` file\. To see this information, use the cdk context command without any options\. The output should be something like the following\.
```
Context found in cdk.json:
βββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β # β Key β Value β
βββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1 β availability-zones:account=123456789012:region=eu-central-1 β [ "eu-central-1a", "eu-central-1b", "eu-central-1c" ] β
βββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2 β availability-zones:account=123456789012:region=eu-west-1 β [ "eu-west-1a", "eu-west-1b", "eu-west-1c" ] β
βββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Run cdk context --reset KEY_OR_NUMBER to remove a context key. If it is a cached value, it will be refreshed on the next cdk synth.
```
To remove a context value, run cdk context \-\-reset, specifying the value's corresponding key or number\. The following example removes the value that corresponds to the second key in the preceding example, which is the list of availability zones in the Ireland region\.
```
cdk context --reset 2
```
```
Context value
availability-zones:account=123456789012:region=eu-west-1
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
676ccf1ee29e-1
|
```
Context value
availability-zones:account=123456789012:region=eu-west-1
reset. It will be refreshed on the next SDK synthesis run.
```
Therefore, if you want to update to the latest version of the Amazon Linux AMI, you can use the preceding example to do a controlled update of the context value and reset it, and then synthesize and deploy your app again\.
```
cdk synth
```
To clear all of the stored context values for your app, run cdk context \-\-clear, as follows\.
```
cdk context --clear
```
Only context values stored in `cdk.context.json` can be reset or cleared\. The AWS CDK does not touch other context files\. To protect a context value from being reset using these commands, then, you might copy the value to `cdk.json`\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
1daee6a2a5de-0
|
Use the `--context` \(`-c` for short\) option to pass runtime context values to your CDK app during synthesis or deployment\.
```
cdk synth --context key=value MyStack
```
To specify multiple context values, repeat the \-\-context option any number of times, providing one key\-value pair each time\.
```
cdk synth --context key1=value1 --context key2=value2 MyStack
```
When deploying multiple stacks, the specified context values are normally passed to all of them\. If you wish, you may specify different values for each stack by prefixing the stack name to the context value\.
```
cdk synth --context Stack1:key=value --context Stack2:key=value Stack1 Stack2
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
b495c3440afd-0
|
Below is an example of importing an existing Amazon VPC using AWS CDK context\.
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
ddba064c5764-0
|
```
import * as cdk from '@aws-cdk/core';
import * as ec2 from '@aws-cdk/aws-ec2';
export class ExistsVpcStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpcid = this.node.tryGetContext('vpcid');
const vpc = ec2.Vpc.fromLookup(this, 'VPC', {
vpcId: vpcid,
});
const pubsubnets = vpc.selectSubnets({subnetType: ec2.SubnetType.PUBLIC});
new cdk.CfnOutput(this, 'publicsubnets', {
value: pubsubnets.subnetIds.toString(),
});
}
}
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
669519094330-0
|
```
const cdk = require('@aws-cdk/core');
const ec2 = require('@aws-cdk/aws-ec2');
class ExistsVpcStack extends cdk.Stack {
constructor(scope, id, props) {
super(scope, id, props);
const vpcid = this.node.tryGetContext('vpcid');
const vpc = ec2.Vpc.fromLookup(this, 'VPC', {
vpcId: vpcid
});
const pubsubnets = vpc.selectSubnets({subnetType: ec2.SubnetType.PUBLIC});
new cdk.CfnOutput(this, 'publicsubnets', {
value: pubsubnets.subnetIds.toString()
});
}
}
module.exports = { ExistsVpcStack }
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
dd1e89d02e7b-0
|
```
import aws_cdk.core as cdk
import aws_cdk.aws_ec2 as ec2
class ExistsVpcStack(cdk.Stack):
def __init__(scope: cdk.Construct, id: str, **kwargs):
super().__init__(scope, id, **kwargs)
vpcid = self.node.try_get_context("vpcid");
vpc = ec2.Vpc.from_lookup(self, "VPC", vpc_id=vpcid)
pubsubnets = vpc.select_subnets(subnetType=ec2.SubnetType.PUBLIC);
cdk.CfnOutput(self, "publicsubnets",
value=pubsubnets.subnet_ids.to_string())
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
cc6aa4a9ba98-0
|
```
import software.amazon.awscdk.core.CfnOutput;
import software.amazon.awscdk.services.ec2.Vpc;
import software.amazon.awscdk.services.ec2.VpcLookupOptions;
import software.amazon.awscdk.services.ec2.SelectedSubnets;
import software.amazon.awscdk.services.ec2.SubnetSelection;
import software.amazon.awscdk.services.ec2.SubnetType;
public class ExistsVpcStack extends Stack {
public ExistsVpcStack(App context, String id) {
this(context, id, null);
}
public ExistsVpcStack(App context, String id, StackProps props) {
super(context, id, props);
String vpcId = (String)this.getNode().tryGetContext("vpcid");
Vpc vpc = (Vpc)Vpc.fromLookup(this, "VPC", VpcLookupOptions.builder()
.vpcId(vpcId).build());
SelectedSubnets pubSubNets = vpc.selectSubnets(SubnetSelection.builder()
.subnetType(SubnetType.PUBLIC).build());
CfnOutput.Builder.create(this, "publicsubnets")
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
cc6aa4a9ba98-1
|
CfnOutput.Builder.create(this, "publicsubnets")
.value(pubSubNets.getSubnetIds().toString()).build();
}
}
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
5ec589e5e449-0
|
```
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
class ExistsVpcStack : Stack
{
public ExistsVpcStack(App scope, string id, StackProps props) : base(scope, id, props)
{
var vpcId = (string)this.Node.TryGetContext("vpcid");
var vpc = Vpc.FromLookup(this, "VPC", new VpcLookupOptions
{
VpcId = vpcId
});
SelectedSubnets pubSubNets = vpc.SelectSubnets([new SubnetSelection
{
SubnetType = SubnetType.PUBLIC
}]);
new CfnOutput(this, "publicsubnets", new CfnOutputProps {
Value = pubSubNets.SubnetIds.ToString()
});
}
}
```
------
You can use cdk diff to see the effects of passing in a context value on the command line:
```
cdk diff -c vpcid=vpc-0cb9c31031d0d3e22
```
```
Stack ExistsvpcStack
Outputs
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
5ec589e5e449-1
|
```
```
Stack ExistsvpcStack
Outputs
[+] Output publicsubnets publicsubnets: {"Value":"subnet-06e0ea7dd302d3e8f,subnet-01fc0acfb58f3128f"}
```
The resulting context values can be viewed as shown here\.
```
cdk context -j
```
```
{
"vpc-provider:account=123456789012:filter.vpc-id=vpc-0cb9c31031d0d3e22:region=us-east-1": {
"vpcId": "vpc-0cb9c31031d0d3e22",
"availabilityZones": [
"us-east-1a",
"us-east-1b"
],
"privateSubnetIds": [
"subnet-03ecfc033225be285",
"subnet-0cded5da53180ebfa"
],
"privateSubnetNames": [
"Private"
],
"privateSubnetRouteTableIds": [
"rtb-0e955393ced0ada04",
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
5ec589e5e449-2
|
"privateSubnetRouteTableIds": [
"rtb-0e955393ced0ada04",
"rtb-05602e7b9f310e5b0"
],
"publicSubnetIds": [
"subnet-06e0ea7dd302d3e8f",
"subnet-01fc0acfb58f3128f"
],
"publicSubnetNames": [
"Public"
],
"publicSubnetRouteTableIds": [
"rtb-00d1fdfd823c82289",
"rtb-04bb1969b42969bcb"
]
}
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/context.md
|
105331a3dd26-0
|
Aspects are the way to apply an operation to all constructs in a given scope\. The functionality could modify the constructs, such as by adding tags, or it could be verifying something about the state of the constructs, such as ensuring that all buckets are encrypted\.
To apply an aspect to a construct and all constructs in the same scope, call [node\.applyAspect](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.ConstructNode.html#apply-aspectaspect) \(Python: `apply_aspect`\) with a new aspect, as shown in the following example\.
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
2375328fc511-0
|
```
myConstruct.node.applyAspect(new SomeAspect(/*...*/));
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
8bb7d75ec7f0-0
|
```
myConstruct.node.applyAspect(new SomeAspect());
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
c837115b7ade-0
|
```
my_construct.node.apply_aspect(SomeAspect(...))
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
9451fb20d8df-0
|
```
myConstruct.getNode().applyAspect(new SomeAspect(...));
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
c88587a44853-0
|
```
myConstruct.Node.ApplyAspect(new SomeAspect(...));
```
------
The AWS CDK currently uses aspects only to [tag resources](tagging.md), but the framework is extensible and can also be used for other purposes\. For example, you can use it to validate or change the AWS CloudFormation resources that are defined for you\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
f169932ad8c6-0
|
The AWS CDK implements tagging using a more generic system, called *aspects*, which is an instance of the visitor pattern\. An aspect is a class that implements the following interface\.
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
d2f0d661c67b-0
|
```
interface IAspect {
visit(node: IConstruct): void;}
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
038e0a56b14d-0
|
JavaScript doesn't have interfaces as a language feature, so an aspect is simply an instance of a class having a `visit` method that accepts the node to be operated on\.
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
f66e22102452-0
|
Python doesn't have interfaces as a language feature, so an aspect is simply an instance of a class having a `visit` method that accepts the node to be operated on\.
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
77516300ea13-0
|
```
public interface IAspect {
public void visit(Construct node);
}
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
971fc96f550f-0
|
```
public interface IAspect
{
void Visit(IConstruct node);
}
```
------
When you call `construct.node.applyAspect(aspect)` \(Python: `apply_aspect`\) the construct adds the aspect to an internal list of aspects\.
During the [prepare phase](apps.md#lifecycle), the AWS CDK calls the `visit` method of the object for the construct and each of its children in top\-down order\.
Although the aspect object is free to change any aspect of the construct object, it only operates on a specific subset of construct types\. After determining the construct type, it can call any method and inspect or assign any property on the construct\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
e378e2199170-0
|
The following example validates that all buckets created in the stack have versioning enabled\. The aspect adds an error to the constructs that fail the validation, which results in the synth operation failing and prevents deploying the resulting cloud assembly\.
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
a8bc80a03b48-0
|
```
class BucketVersioningChecker implements IAspect {
public visit(node: IConstruct): void {
// See that we're dealing with a CfnBucket
if (node instanceof s3.CfnBucket) {
// Check for versioning property, exclude the case where the property
// can be a token (IResolvable).
if (!node.versioningConfiguration
|| (!Tokenization.isResolvable(node.versioningConfiguration)
&& node.versioningConfiguration.status !== 'Enabled')) {
node.node.addError('Bucket versioning is not enabled');
}
}
}
}
// Apply to the stack
stack.node.applyAspect(new BucketVersioningChecker());
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
788000f9e09c-0
|
```
class BucketVersioningChecker {
visit(node) {
// See that we're dealing with a CfnBucket
if ( node instanceof s3.CfnBucket) {
// Check for versioning property, exclude the case where the property
// can be a token (IResolvable).
if ( !node.versioningConfiguration
|| !Tokenization.isResolvable(node.versioningConfiguration)
&& node.versioningConfiguration.status !== 'Enabled') {
node.node.addError('Bucket versioning is not enabled');
}
}
}
}
// Apply to the stack
stack.node.applyAspect(new BucketVersioningChecker());
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
798eb1615e36-0
|
```
@jsii.implements(core.IAspect)
class BucketVersioningChecker:
def visit(self, node):
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
ddd67ef7d852-0
|
if isinstance(node, s3.CfnBucket):
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
0568ed37dba4-0
|
if (!node.versioning_configuration or
!Tokenization.is_resolvable(node.versioning_configuration)
and node.versioning_configuration.status != "Enabled"):
node.node.add_error('Bucket versioning is not enabled')
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
bbf20de9bed0-0
|
stack.node.apply_aspect(BucketVersioningChecker())
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
536cd2e76929-0
|
```
public class BucketVersioningChecker implements IAspect
{
@Override
public void visit(Construct node)
{
// See that we're dealing with a CfnBucket
if (node instanceof CfnBucket)
{
CfnBucket bucket = (CfnBucket)node;
Object versioningConfiguration = bucket.getVersioningConfiguration();
if (versioningConfiguration == null ||
!Tokenization.isResolvable(versioningConfiguration.toString()) &&
!versioningConfiguration.toString().contains("Enabled")
bucket.getNode().addError("Bucket versioning is not enabled");
}
}
}
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
cb09e42f707b-0
|
```
class BucketVersioningChecker : Amazon.Jsii.Runtime.DeputyBase, IAspect
{
public void Visit(IConstruct node)
{
// See that we're dealing with a CfnBucket
if (node is CfnBucket)
{
var bucket = (CfnBucket)node;
if (bucket.VersioningConfiguration is null ||
!Tokenization.IsResolvable(bucket.VersioningConfiguration) &&
!bucket.VersioningConfiguration.ToString().Contains("Enabled")
bucket.Node.AddError("Bucket versioning is not enabled");
}
}
}
```
------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/aspects.md
|
09a0bd55f6cf-0
|
Enjoy these videos presented by members of the AWS CDK team\.
**Note**
Since the AWS CDK is always evolving, some of the code presented in these videos may not work quite the same way it did when the video was recorded\. This is especially true for modules that were under active development at the time\. It's also possible that we've since added a better way to achieve the same result\. Consult this Developer Guide and the [AWS CDK API Reference](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html) for up\-to\-date information\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/videos.md
|
15e3ec65df50-0
|
The AWS CDK Toolkit, the CLI command `cdk`, is the primary tool for interacting with your AWS CDK app\. It executes your app, interrogates the application model you defined, and produces and deploys the AWS CloudFormation templates generated by the AWS CDK\. It also provides other features useful for creating and working with AWS CDK projects\. This topic contains information about common use cases of the CDK Toolkit\.
The AWS CDK Toolkit is installed with the Node Package Manager\. In most cases, we recommend installing it globally\.
```
npm install -g aws-cdk # install latest version
npm install -g aws-cdk@X.YY.Z # install specific version
```
**Tip**
If you regularly work with multiple versions of the AWS CDK, you may want to install a matching version of the AWS CDK Toolkit in individual CDK projects\. To do this, omit `-g` from the `npm install` command\. Then use `npx cdk` to invoke it; this will run the local version if one exists, falling back to a global version if not\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
bf3a06688be1-0
|
All CDK Toolkit commands start with `cdk`, which is followed by a subcommand \(`list`, `synthesize`, `deploy`, etc\.\)\. Some subcommands have a shorter version \(`ls`, `synth`, etc\.\) that is equivalent\. Options and arguments follow the subcommand in any order\. The available commands are summarized here\.
| Command | Function |
| --- | --- |
| `cdk list` \(`ls`\) | Lists the stacks in the app |
| `cdk synthesize` \(`synth`\) | Synthesizes and prints the CloudFormation template for the specified stack\(s\) |
| `cdk bootstrap` | Deploys the CDK Toolkit stack; see [Bootstrapping](bootstrapping.md) |
| `cdk deploy` | Deploys the specified stack\(s\) |
| `cdk destroy` | Destroys the specified stack\(s\) |
| `cdk diff` | Compares the specified stack with the deployed stack or a local CloudFormation template |
| `cdk metadata` | Displays metadata about the specified stack |
| `cdk init` | Creates a new CDK project in the current directory from a specified template |
| `cdk context` | Manages cached context values |
| `cdk docs` \(`doc`\) | Opens the CDK API reference in your browser |
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
bf3a06688be1-1
|
| `cdk docs` \(`doc`\) | Opens the CDK API reference in your browser |
| `cdk doctor` | Checks your CDK project for potential problems |
For the options available for each command, see [Toolkit reference](#cli-ref) or [Built\-in help](#cli-help)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
ed13dc3d9dcd-0
|
The AWS CDK Toolkit has integrated help\. You can see general help about the utility and a list of the provided subcommands by issuing:
```
cdk --help
```
To see help for a particular subcommand, for example `deploy`, specify it before the `--help` flag\.
```
cdk deploy --help
```
Issue `cdk version` to display the version of the AWS CDK Toolkit\. Provide this information when requesting support\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
e53ada497eeb-0
|
To gain insight into how the AWS CDK is used, the versions of libraries used by AWS CDK applications are collected and reported by using a resource identified as `AWS::CDK::Metadata`\. This resource is added to AWS CloudFormation templates, and can easily be reviewed\. This information can also be used to identify stacks using a package with known serious security or reliability issues, and to contact their users with important information\.
By default, the AWS CDK reports the name and version of the following NPM modules that are loaded at synthesis time:
+ AWS CDK core module
+ AWS Construct Library modules
+ AWS Solutions Constructs module
+ AWS Render Farm Deployment Kit module
The `AWS::CDK::Metadata` resource looks something like the following\.
```
CDKMetadata:
Type: "AWS::CDK::Metadata"
Properties:
Modules: "@aws-cdk/core=X.YY.Z,@aws-cdk/s3=X.YY.Z,@aws-solutions-consturcts/aws-apigateway-lambda=X.YY.Z,aws-rfdk=X.YY.Z"
```
To opt out of version reporting, use one of the following methods:
+ Use the cdk command with the \-\-no\-version\-reporting argument to opt out for a single command\.
```
cdk --no-version-reporting synth
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
e53ada497eeb-1
|
```
cdk --no-version-reporting synth
```
Remember, the AWS CDK Toolkit synthesizes fresh templates before deploying, so you should also add `--no-version-reporting` to `cdk deploy` commands\.
+ Set versionReporting to **false** in `./cdk.json` or `~/.cdk.json`\. This opts out unless you opt in by specifying `--version-reporting` on an individual command\.
```
{
"app": "...",
"versionReporting": false
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
bf937c03e2cf-0
|
In AWS CDK terms, the [environment](environments.md) consists of a region and AWS credentials valid in that region\. The CDK Toolkit needs credentials in order to query your AWS account and to deploy CloudFormation templates\.
**Important**
We strongly recommend against using your AWS root account for day\-to\-day tasks\. Instead, create a user in IAM and use its credentials with the CDK\.
If you have the AWS CLI installed, the easiest way to satisfy this requirement is to install the AWS CLI and issue the following command:
```
aws configure
```
Provide your AWS access key ID, secret access key, and default region when prompted\.
You may also manually create or edit the `~/.aws/config` and `~/.aws/credentials` \(Mac OS X or Linux\) or `%USERPROFILE%\.aws\config` and `%USERPROFILE%\.aws\credentials` \(Windows\) files to contain credentials and a default region, in the following format\.
+ In `~/.aws/config` or `%USERPROFILE%\.aws\config`
```
[default]
region=us-west-2
```
+ In `~/.aws/credentials` or `%USERPROFILE%\.aws\credentials`
```
[default]
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
bf937c03e2cf-1
|
```
[default]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
```
Besides specifying AWS credentials and a region under the `[default]` section, you can also put them in a `[profile NAME]` section, where *NAME* is the name of the profile\. You can add any number of named profiles, with or without a `[default]` section\. Be sure to add the same profile sections to both the configuration and credentials files\.
**Tip**
Don't name a profile `default`\. That's just confusing\.
Use the `--profile` flag to choose a set of credentials and default region from these configuration files for a given command\.
```
cdk deploy --profile test PipelineStack
```
Instead of using the configuration files, you can set the environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_DEFAULT_REGION` to appropriate values\.
You may optionally use the `--role-arn` \(or `-r`\) option to specify the ARN of an IAM role that should be used for deployment\. This role must be assumable by the AWS account being used\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
ec16aab8f93c-0
|
Many features of the CDK Toolkit require one or more AWS CloudFormation templates be synthesized, which in turn requires running your application\. Since the AWS CDK supports programs written in a variety of languages, it uses a configuration option to specify the exact command necessary to run your app\. This option can be specified in two ways\.
First, and most commonly, it can be specified using the `app` key inside the file `cdk.json`, which is in the main directory of your AWS CDK project\. The CDK Toolkit provides an appropriate command when creating a new project with `cdk init`\. Here is the `cdk.json` from a fresh TypeScript project, for instance\.
```
{
"app": "npx ts-node bin/hello-cdk.ts"
}
```
The CDK Toolkit looks for `cdk.json` in the current working directory when attempting to run your app, so you might keep a shell open in your project's main directory for issuing CDK Toolkit commands\.
The CDK Toolkit also looks for the app key in `~/.cdk.json` \(that is, in your home directory\) if it can't find it in `./cdk.json`\. Adding the app command here can be useful if you usually work with CDK code in the same language, as it does not require you to be in the app's main directory when you run a `cdk` command\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
ec16aab8f93c-1
|
If you are in some other directory, or if you want to run your app via a command other than the one in `cdk.json`, you can use the `--app` \(or `-a`\) option to specify it\.
```
cdk --app "npx ts-node bin/hello-cdk.ts" ls
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
f2b0fa76a126-0
|
Many CDK Toolkit commands \(for example, `cdk deploy`\) work on stacks defined in your app\. If your app contains only one stack, the CDK Toolkit assumes you mean that one if you don't specify a stack explicitly\.
Otherwise, you must specify the stack or stacks you want to work with\. You can do this by specifying the desired stacks by ID individually on the command line\. Recall that the ID is the value specified by the second argument when you instantiate the stack\.
```
cdk synth PipelineStack LambdaStack
```
You may also use wildcards to specify IDs that match a pattern\.
+ ? matches any single character
+ \* matches any number of characters
When using wildcards, enclose the pattern in quotes\. If you don't, your shell may try to expand the pattern to the names of files in the current directory\. At best, this won't do what you expect; at worst, you could deploy stacks you didn't intend to\.
```
cdk synth "*Stack" # PipelineStack, LambdaStack, etc.
cdk synth "Stack?" # StackA, StackB, Stack1, etc.
cdk synth "*" # All stacks in the app
```
**Note**
The CDK Toolkit does not guarantee that stacks are processed in the specified order\. If for some reason the order of the stacks is important, use multiple `cdk` commands\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
ed1a87a9b63d-0
|
Deploying stacks that contain [assets](assets.md), synthesize to large templates, or use [CDK Pipelines](cdk_pipeline.md) require special dedicated AWS CDK resources to be provisioned\. The `cdk bootstrap` command creates the necessary resources for you\. You only need to bootstrap if you are deploying a stack that requires these dedicated resources\. See [Bootstrapping](bootstrapping.md) for details\.
```
cdk bootstrap # bootstraps default account/region
cdk bootstrap --profile test # bootstraps test environment
```
You may also bootstrap a specific environment\. Credentials must be configured \(e\.g\. in `~/.aws/credentials`\) for the specified account and region\. You may specify a profile that contains the required credentials\.
```
cdk bootstrap ACCOUNT-NUMBER/REGION # e.g.
cdk bootstrap 1111111111/us-east-1
cdk bootstrap --profile test 1111111111/us-east-1
```
**Important**
Each environment \(account/region combination\) to which you deploy such a stack must be bootstrapped separately\.
You may incur AWS charges for what the AWS CDK stores in the bootstrapped resources\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
279f98c60c4b-0
|
To create a new app, create a directory for it, then, inside the directory, issue `cdk init`\.
```
mkdir my-cdk-app
cd my-cdk-app
cdk init TEMPLATE --language LANGUAGE
```
The supported languages \(*LANGUAGE*\) are:
| Code | Language |
| --- | --- |
| `typescript` | TypeScript |
| `javascript` | JavaScript |
| `python` | Python |
| `java` | Java |
| `csharp` | C\# |
*TEMPLATE* is an optional template\. If the desired template is *app*, the default, you may omit it\. The available templates are:
| Template | Description |
| --- | --- |
| `app`Β \(default\) | Creates an empty AWS CDK app\. |
| `sample-app` | Creates an AWS CDK app with a stack containing an Amazon SQS queue and an Amazon SNS topic\. |
The templates use the name of the project folder to generate names for files and classes inside your new app\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
4799356c4a90-0
|
To see a list of the IDs of the stacks in your AWS CDK application, enter one of the following equivalent commands:
```
cdk list
cdk ls
```
If your app contains many stacks, you can specify full or partial stack IDs of the stacks to be listed; see [Specifying stacks](#cli-stacks)\.
Add the `--long` flag to see more information about the stacks, including the stack names and their environments \(AWS account and region\)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
b3188d15d13b-0
|
The `cdk synthesize` command \(almost always abbreviated `synth`\) synthesizes a stack defined in your app into a CloudFormation template\.
```
cdk synth # if app contains only one stack
cdk synth MyStack
cdk synth Stack1 Stack2
cdk synth "*" # all stacks in app
```
**Note**
The CDK Toolkit actually runs your app and synthesizes fresh templates before most operations \(e\.g\. when deploying or comparing stacks\)\. These templates are stored by default in the `cdk.out` directory\. The `cdk synth` command simply prints the generated templates for the specified stack\(s\)\.
See `cdk synth --help` for all available options\. A few of the most\-frequently\-used options are covered below\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
ce6d029a44f2-0
|
Use the `--context` or `-c` option to pass [runtime context](context.md) values to your CDK app\.
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
f6a250a24898-0
|
cdk synth βcontext key=value MyStack
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
69e218ec3ed5-0
|
cdk synth --context key1=value1 --context key2=value2 MyStack
```
When deploying multiple stacks, the specified context values are normally passed to all of them\. If you wish, you may specify different values for each stack by prefixing the stack name to the context value\.
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
6badefc21e19-0
|
cdk synth --context Stack1:key=value Stack2:key=value Stack1 Stack2
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
4ba39f928b2a-0
|
By default, the synthesized template is displayed in YAML format\. Add the `--json` flag to display it in JSON format instead\.
```
cdk synth βjson MyStack
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
614d84385dd9-0
|
Add the `--output` \(`-o`\) option to write the synthesized templates to a directory other than `cdk.out`\.
```
cdk synth βoutput=~/templates
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
23800ceb0c52-0
|
The `cdk deploy` subcommand deploys the specified stack\(s\) to your AWS account\.
```
cdk deploy # if app contains only one stack
cdk deploy MyStack
cdk deploy Stack1 Stack2
cdk deploy "*" # all stacks in app
```
**Note**
The CDK Toolkit runs your app and synthesizes fresh AWS CloudFormation templates before deploying anything\. Therefore, most command line options you can use with `cdk synth` \(for example, `--context`\) can also be used with `cdk deploy`\.
See `cdk deploy --help` for all available options\. A few of the most\-frequently\-used options are covered below\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
07f0de793390-0
|
The AWS CDK Toolkit supports specifying AWS CloudFormation [parameters](parameters.md) at deployment\. You may provide these on the command line following the `--parameters` flag\.
```
cdk deploy MyStack --parameters uploadBucketName=UploadBucket
```
To define multiple parameters, use multiple `--parameters` flags\.
```
cdk deploy MyStack --parameters uploadBucketName=UpBucket --parameters downloadBucketName=DownBucket
```
If you are deploying multiple stacks, you can specify a different value of each parameter for each stack by prefixing the name of the parameter with the stack name and a colon\. Otherwise, the same value is passed to all stacks\.
```
cdk deploy MyStack YourStack --parameters MyStack:uploadBucketName=UploadBucket --parameters YourStack:uploadBucketName=UpBucket
```
By default, the AWS CDK retains values of parameters from previous deployments and uses them in later deployments if they are not specified explicitly\. Use the `--no-previous-parameters` flag to require all parameters to be specified\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
d82918474dfd-0
|
If your stack declares AWS CloudFormation outputs, these are normally displayed on the screen at the conclusion of deployment\. To write them to a file in JSON format, use the `--output-file` flag\.
```
cdk deploy βoutput-file outputs.json MyStack
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
4e7211212148-0
|
To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security\-related changes before deploying them\.
You can change the level of change that requires approval by specifying:
```
cdk deploy --require-approval LEVEL
```
*LEVEL* can be one of the following:
| Term | Meaning |
| --- | --- |
| `never` | Approval is never required |
| `any-change` | Requires approval on any IAM or security\-group\-related change |
| `broadening`Β \(default\) | Requires approval when IAM statements or traffic rules are added; removals don't require approval |
The setting can also be configured in the `cdk.json` file\.
```
{
"app": "...",
"requireApproval": "never"
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
2202cf247ba8-0
|
The `cdk diff` command compares the current version of a stack defined in your app with the already\-deployed version, or with a saved AWS CloudFormation template, and displays a list of differences\.
```
[~] AWS::S3::Bucket MyFirstBucket MyFirstBucketB8884501
ββ [~] DeletionPolicy
β ββ [-] Retain
β ββ [+] Delete
ββ [~] UpdateReplacePolicy
ββ [-] Retain
ββ [+] Delete
```
To compare your app's stack\(s\) with the existing deployment:
```
cdk diff MyStack
```
To compare your app's stack\(s\) with a saved CloudFormation template:
```
cdk diff --template ~/stacks/MyStack.old MyStack
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
f1f072912211-0
|
This section provides a reference for the AWS CDK Toolkit derived from its help, first a general reference with the options available with all commands, then \(in collapsible sections\) specific references with options available only with specific subcommands\.
```
Usage: cdk -a <cdk-app> COMMAND
Commands:
cdk list [STACKS..] Lists all stacks in the app [aliases: ls]
cdk synthesize [STACKS..] Synthesizes and prints the CloudFormation
template for this stack [aliases: synth]
cdk bootstrap [ENVIRONMENTS..] Deploys the CDK toolkit stack into an AWS
environment
cdk deploy [STACKS..] Deploys the stack(s) named STACKS into your
AWS account
cdk destroy [STACKS..] Destroy the stack(s) named STACKS
cdk diff [STACKS..] Compares the specified stack with the deployed
stack or a local template file, and returns
with status 1 if any difference is found
cdk metadata [STACK] Returns all metadata associated with this
stack
cdk init [TEMPLATE] Create a new, empty CDK project from a
template. Invoked without TEMPLATE, the app
template will be used.
cdk context Manage cached context values
cdk docs Opens the reference documentation in a browser
[aliases: doc]
cdk doctor Check your set-up for potential problems
Options:
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
f1f072912211-1
|
[aliases: doc]
cdk doctor Check your set-up for potential problems
Options:
--app, -a REQUIRED: command-line for executing your app or a cloud
assembly directory (e.g. "node bin/my-app.js") [string]
--context, -c Add contextual string parameter (KEY=VALUE) [array]
--plugin, -p Name or path of a node package that extend the CDK
features. Can be specified multiple times [array]
--trace Print trace for stack warnings [boolean]
--strict Do not construct stacks with warnings [boolean]
--ignore-errors Ignores synthesis errors, which will likely produce an
invalid output [boolean] [default: false]
--json, -j Use JSON output instead of YAML when templates are
printed to STDOUT [boolean] [default: false]
--verbose, -v Show debug logs (specify multiple times to increase
verbosity) [count] [default: false]
--profile Use the indicated AWS profile as the default environment
[string]
--proxy Use the indicated proxy. Will read from HTTPS_PROXY
environment variable if not specified. [string]
--ca-bundle-path Path to CA certificate to use when validating HTTPS
requests. Will read from AWS_CA_BUNDLE environment
variable if not specified. [string]
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
f1f072912211-2
|
requests. Will read from AWS_CA_BUNDLE environment
variable if not specified. [string]
--ec2creds, -i Force trying to fetch EC2 instance credentials. Default:
guess EC2 instance status. [boolean]
--version-reporting Include the "AWS::CDK::Metadata" resource in synthesized
templates (enabled by default) [boolean]
--path-metadata Include "aws:cdk:path" CloudFormation metadata for each
resource (enabled by default) [boolean] [default: true]
--asset-metadata Include "aws:asset:*" CloudFormation metadata for
resources that user assets (enabled by default)
[boolean] [default: true]
--role-arn, -r ARN of Role to use when invoking CloudFormation [string]
--toolkit-stack-name The name of the CDK toolkit stack [string]
--staging Copy assets to the output directory (use --no-staging to
disable, needed for local debugging the source files
with SAM CLI) [boolean] [default: true]
--output, -o Emits the synthesized cloud assembly into a directory
(default: cdk.out) [string]
--no-color Removes colors and other style from console output
[boolean] [default: false]
--fail Fail with exit code 1 in case of diff
[boolean] [default: false]
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
f1f072912211-3
|
--fail Fail with exit code 1 in case of diff
[boolean] [default: false]
--version Show version number [boolean]
-h, --help Show help [boolean]
If your app has a single stack, there is no need to specify the stack name
If one of cdk.json or ~/.cdk.json exists, options specified there will be used
as defaults. Settings in cdk.json take precedence.
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
51f4225398ff-0
|
```
cdk list [STACKS..]
Lists all stacks in the app
Options:
--long, -l Display environment information for each stack
[boolean] [default: false]
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
ea420fa5fc92-0
|
```
cdk synthesize [STACKS..]
Synthesizes and prints the CloudFormation template for this stack
Options:
--exclusively, -e Only synthesize requested stacks, don't include
dependencies [boolean]
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
e150c2fa6a4c-0
|
```
cdk bootstrap [ENVIRONMENTS..]
Deploys the CDK toolkit stack into an AWS environment
Options:
--bootstrap-bucket-name, -b, The name of the CDK toolkit bucket;
--toolkit-bucket-name bucket will be created and must not
exist [string]
--bootstrap-kms-key-id AWS KMS master key ID used for the
SSE-KMS encryption [string]
--qualifier Unique string to distinguish
multiple bootstrap stacks [string]
--public-access-block-configuration Block public access configuration
on CDK toolkit bucket (enabled by
default) [boolean]
--tags, -t Tags to add for the stack
(KEY=VALUE) [array] [default: []]
--execute Whether to execute ChangeSet
(--no-execute will NOT execute the
ChangeSet) [boolean] [default: true]
--force, -f Always bootstrap even if it would
downgrade template version
[boolean] [default: false]
--termination-protection Toggle CloudFormation termination
protection on the bootstrap stacks
[boolean]
--show-template Instead of actual bootstrapping,
print the current CLI's
bootstrapping template to stdout for
customization.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
e150c2fa6a4c-1
|
print the current CLI's
bootstrapping template to stdout for
customization.
[boolean] [default: false]
--template Use the template from the given file
instead of the built-in one (use
--show-template to obtain an
example). [string]
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
1ed1f95d312f-0
|
```
cdk deploy [STACKS..]
Deploys the stack(s) named STACKS into your AWS account
Options:
--build-exclude, -E Do not rebuild asset with the given ID. Can be
specified multiple times. [array] [default: []]
--exclusively, -e Only deploy requested stacks, don't include
dependencies [boolean]
--require-approval What security-sensitive changes need manual approval
[string] [choices: "never", "any-change", "broadening"]
--ci Force CI detection [boolean] [default: false]
--notification-arns ARNs of SNS topics that CloudFormation will notify with
stack related events [array]
--tags, -t Tags to add to the stack (KEY=VALUE), overrides tags
from Cloud Assembly [array]
--execute Whether to execute ChangeSet (--no-execute will NOT
execute the ChangeSet) [boolean] [default: true]
--force, -f Always deploy stack even if templates are identical
[boolean] [default: false]
--parameters Additional parameters passed to CloudFormation at
deploy time (STACK:KEY=VALUE) [array] [default: {}]
--outputs-file, -O Path to file where stack outputs will be written as
JSON [string]
--previous-parameters Use previous values for existing parameters (you must
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
1ed1f95d312f-1
|
JSON [string]
--previous-parameters Use previous values for existing parameters (you must
specify all parameters on every deployment if this is
disabled) [boolean] [default: true]
--progress Display mode for stack activity events.
[string] [choices: "bar", "events"]
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
5a28b973ac1e-0
|
```
cdk destroy [STACKS..]
Destroy the stack(s) named STACKS
Options:
--exclusively, -e Only destroy requested stacks, don't include dependees
[boolean]
--force, -f Do not ask for confirmation before destroying the stacks
[boolean]
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
e771c55e1c6d-0
|
```
cdk diff [STACKS..]
Compares the specified stack with the deployed stack or a local template file,
and returns with status 1 if any difference is found
Options:
--exclusively, -e Only diff requested stacks, don't include dependencies
[boolean]
--context-lines Number of context lines to include in arbitrary JSON
diff rendering [number] [default: 3]
--template The path to the CloudFormation template to compare with
[string]
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
297dabd1609e-0
|
```
cdk init [TEMPLATE]
Create a new, empty CDK project from a template. Invoked without TEMPLATE, the
app template will be used.
Options:
--language, -l The language to be used for the new project (default can
be configured in ~/.cdk.json)
[string] [choices: "csharp", "fsharp", "java", "javascript", "python",
"typescript"]
--list List the available templates [boolean]
--generate-only If true, only generates project files, without executing
additional operations such as setting up a git repo,
installing dependencies or compiling the project
[boolean] [default: false]
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
bfddaf4c7f4a-0
|
```
cdk context
Manage cached context values
Options:
--reset, -e The context key (or its index) to reset [string]
--clear Clear all context [boolean]
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/cli.md
|
cc1664c4ce11-0
|
This topic introduces you to important AWS CDK concepts and describes how to install and configure the AWS CDK\. When you're done, you'll be ready to create [your first AWS CDK app](hello_world.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/getting_started.md
|
04043de77f2f-0
|
The AWS Cloud Development Kit \(AWS CDK\) lets you define your cloud infrastructure as code in one of five supported programming languages\. It is intended for moderately to highly experienced AWS users\.
Ideally, you already have experience with popular AWS services, particularly [AWS Identity and Access Management](https://aws.amazon.com/iam/) \(IAM\)\. You might already have AWS credentials on your workstation for use with an AWS SDK or the AWS CLI and experience working with AWS resources programmatically\.
Familiarity with [AWS CloudFormation](https://aws.amazon.com/cloudformation/) is also useful, as the output of an AWS CDK program is a AWS CloudFormation template\.
Finally, you should be proficient in the programming language you intend to use with the AWS CDK\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/getting_started.md
|
8da15bab7234-0
|
The AWS CDK is designed around a handful of important concepts\. We will introduce a few of these here briefly\. Follow the links to learn more, or see the Concepts topics in this guide's Table of Contents\.
An AWS CDK [app](apps.md) is an application written in TypeScript, JavaScript, Python, Java, or C\# that uses the AWS CDK to define AWS infrastructure\. An app defines one or more [stacks](stacks.md)\. Stacks \(equivalent to AWS CloudFormation stacks\) contain [constructs](constructs.md), each of which defines one or more concrete AWS resources, such as Amazon S3 buckets, Lambda functions, Amazon DynamoDB tables, and so on\.
Constructs \(as well as stacks and apps\) are represented as types in your programming language of choice\. You instantiate constructs within a stack to declare them to AWS, and connect them to each other using well\-defined interfaces\.
The AWS CDK includes the AWS CDK Toolkit \(also called the CLI\), a command\-line tool for working with your AWS CDK apps and stacks\. Among other functions, the Toolkit provides the ability to convert one or more AWS CDK stacks to AWS CloudFormation templates and related assets \(a process called *synthesis*\) and to deploy your stacks to an AWS account\.
The AWS CDK includes a library of AWS constructs called the AWS Construct Library\. Each AWS service has at least one corresponding module in the library containing the constructs that represent that service's resources\.
Constructs come in three fundamental flavors:
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/getting_started.md
|
8da15bab7234-1
|
Constructs come in three fundamental flavors:
+ **AWS CloudFormation\-only** or L1 \(short for "level 1"\)\. These constructs correspond directly to resource types defined by AWS CloudFormation\. In fact, these constructs are automatically generated from the AWS CloudFormation specification, so when a new AWS service is launched, the AWS CDK supports it as soon as AWS CloudFormation does\.
AWS CloudFormation resources always have names that begin with `Cfn`\. For example, in the Amazon S3 module, `CfnBucket` is the L1 module for an Amazon S3 bucket\.
+ **Curated** or L2\. These constructs are carefully developed by the AWS CDK team to address specific use cases and simplify infrastructure development\. For the most part, they encapsulate L1 modules, providing sensible defaults and best\-practice security policies\. For example, in the Amazon S3 module, `Bucket` is the L2 module for an Amazon S3 bucket\.
L2 modules may also define supporting resources needed by the primary resource\. Some services have more than one L2 module in the Construct Library for organizational purposes\.
+ **Patterns** or L3\. Patterns declare multiple resources to create entire AWS architectures for particular use cases\. All the plumbing is already hooked up, and configuration is boiled down to a few important parameters\. In the AWS Construct Library, patterns are in separate modules from L1 and L2 constructs\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-cdk-guide/doc_source/getting_started.md
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.