Skip to content

Commit 2da5851

Browse files
committed
Periodic doc update
1 parent 7f30d44 commit 2da5851

22 files changed

+158
-158
lines changed

v2/best-practices.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Stacks define the deployment model of these logical units\. For a more detailed
99

1010
The AWS CDK reflects careful consideration of the needs of our customers and internal teams and of the failure patterns that often arise during the deployment and ongoing maintenance of complex cloud applications\. We discovered that failures are often related to "out\-of\-band" changes to an application that aren't fully tested, such as configuration changes\. Therefore, we developed the AWS CDK around a model in which your entire application is defined in code, not only business logic but also infrastructure and configuration\. That way, proposed changes can be carefully reviewed, comprehensively tested in environments resembling production to varying degrees, and fully rolled back if something goes wrong\.
1111

12-
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/cdk/v2/guide/images/all-in-one.jpg)
12+
![\[\]](http://docs.aws.amazon.com/cdk/v2/guide/images/all-in-one.jpg)
1313

1414
At deployment time, the AWS CDK synthesizes a cloud assembly that contains the following:
1515
+ AWS CloudFormation templates that describe your infrastructure in all target environments
@@ -36,13 +36,13 @@ The CCoE also creates a "landing zone" that defines your organizational units wi
3636

3737
Development teams should be able to use their own accounts for testing and deploy new resources in these accounts as needed\. Individual developers can treat these resources as extensions of their own development workstation\. Using [CDK Pipelines](cdk_pipeline.md), the AWS CDK applications can then be deployed via a CI/CD account to testing, integration, and production environments \(each isolated in its own AWS Region or account\)\. This is done by merging the developers' code into your organization's canonical repository\.
3838

39-
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/cdk/v2/guide/images/best-practice-deploy-to-multiple-accounts.png)
39+
![\[\]](http://docs.aws.amazon.com/cdk/v2/guide/images/best-practice-deploy-to-multiple-accounts.png)
4040

4141
## Coding best practices<a name="best-practices-code"></a>
4242

4343
This section presents best practices for organizing your AWS CDK code\. The following diagram shows the relationship between a team and that team's code repositories, packages, applications, and construct libraries\.
4444

45-
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/cdk/v2/guide/images/code-organization.jpg)
45+
![\[\]](http://docs.aws.amazon.com/cdk/v2/guide/images/code-organization.jpg)
4646

4747
### Start simple and add complexity only when you need it<a name="best-practices-code-kiss"></a>
4848

@@ -137,7 +137,7 @@ What's worse, you can't make changes to the resource that require it to be repla
137137
A better approach is to specify as few names as possible\. If you omit resource names, the AWS CDK will generate them for you in a way that won't cause problems\. Suppose you have a table as a resource\. You can then pass the generated table name as an environment variable into your AWS Lambda function\. In your AWS CDK application, you can reference the table name as `table.tableName`\. Alternatively, you can generate a configuration file on your Amazon EC2 instance on startup, or write the actual table name to the AWS Systems Manager Parameter Store so your application can read it from there\.
138138

139139
If the place you need it is another AWS CDK stack, that's even more straightforward\. Supposing that one stack defines the resource and another stack needs to use it, the following applies:
140-
+ If the two stacks are in the same AWS CDK app, pass a reference between the two stacks\. For example, save a reference to the resource's construct as an attribute of the defining stack \(`this.stack.uploadBucket = myBucket`\)\. Then, pass that attribute to the constructor of the stack that needs the resource\.
140+
+ If the two stacks are in the same AWS CDK app, pass a reference between the two stacks\. For example, save a reference to the resource's construct as an attribute of the defining stack \(`this.stack.uploadBucket = amzn-s3-demo-bucket`\)\. Then, pass that attribute to the constructor of the stack that needs the resource\.
141141
+ When the two stacks are in different AWS CDK apps, use a static `from` method to use an externally defined resource based on its ARN, name, or other attributes\. \(For example, use `Table.fromArn()` for a DynamoDB table\)\. Use the `CfnOutput` construct to print the ARN or other required value in the output of `cdk deploy`, or look in the AWS Management Console\. Alternatively, the second app can read the CloudFormation template generated by the first app and retrieve that value from the `Outputs` section\.
142142

143143
### Define removal policies and log retention<a name="best-practices-apps-removal-logs"></a>
@@ -176,7 +176,7 @@ If you need some value \(from AWS or elsewhere\) for which there is no native CD
176176
With the AWS CDK construct library's `grant()` convenience methods, you can create AWS Identity and Access Management roles that grant access to one resource by another using minimally scoped permissions\. For example, consider a line like the following:
177177

178178
```
179-
myBucket.grantRead(myLambda)
179+
amzn-s3-demo-bucket.grantRead(myLambda)
180180
```
181181

182182
This single line adds a policy to the Lambda function's role \(which is also created for you\)\. That role and its policies are more than a dozen lines of CloudFormation that you don't have to write\. The AWS CDK grants only the minimal permissions required for the function to read from the bucket\.

v2/cfn_layer.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For example, to instantiate a low\-level Amazon S3 bucket L1 with analytics enab
3737
#### [ TypeScript ]
3838

3939
```
40-
new s3.CfnBucket(this, 'MyBucket', {
40+
new s3.CfnBucket(this, 'amzn-s3-demo-bucket', {
4141
analyticsConfigurations: [
4242
{
4343
id: 'Config',
@@ -51,7 +51,7 @@ new s3.CfnBucket(this, 'MyBucket', {
5151
#### [ JavaScript ]
5252

5353
```
54-
new s3.CfnBucket(this, 'MyBucket', {
54+
new s3.CfnBucket(this, 'amzn-s3-demo-bucket', {
5555
analyticsConfigurations: [
5656
{
5757
id: 'Config'
@@ -65,7 +65,7 @@ new s3.CfnBucket(this, 'MyBucket', {
6565
#### [ Python ]
6666

6767
```
68-
s3.CfnBucket(self, "MyBucket",
68+
s3.CfnBucket(self, "amzn-s3-demo-bucket",
6969
analytics_configurations: [
7070
dict(id="Config",
7171
# ...
@@ -78,7 +78,7 @@ s3.CfnBucket(self, "MyBucket",
7878
#### [ Java ]
7979

8080
```
81-
CfnBucket.Builder.create(this, "MyBucket")
81+
CfnBucket.Builder.create(this, "amzn-s3-demo-bucket")
8282
.analyticsConfigurations(Arrays.asList(java.util.Map.of( // Java 9 or later
8383
"id", "Config", // ...
8484
))).build();
@@ -88,7 +88,7 @@ CfnBucket.Builder.create(this, "MyBucket")
8888
#### [ C\# ]
8989

9090
```
91-
new CfnBucket(this, 'MyBucket', new CfnBucketProps {
91+
new CfnBucket(this, 'amzn-s3-demo-bucket', new CfnBucketProps {
9292
AnalyticsConfigurations = new Dictionary<string, string>
9393
{
9494
["id"] = "Config",
@@ -105,7 +105,7 @@ There might be rare cases where you want to define a resource that doesn't have
105105
#### [ TypeScript ]
106106

107107
```
108-
new cdk.CfnResource(this, 'MyBucket', {
108+
new cdk.CfnResource(this, 'amzn-s3-demo-bucket', {
109109
type: 'AWS::S3::Bucket',
110110
properties: {
111111
// Note the PascalCase here! These are CloudFormation identifiers.
@@ -123,7 +123,7 @@ new cdk.CfnResource(this, 'MyBucket', {
123123
#### [ JavaScript ]
124124

125125
```
126-
new cdk.CfnResource(this, 'MyBucket', {
126+
new cdk.CfnResource(this, 'amzn-s3-demo-bucket', {
127127
type: 'AWS::S3::Bucket',
128128
properties: {
129129
// Note the PascalCase here! These are CloudFormation identifiers.
@@ -141,7 +141,7 @@ new cdk.CfnResource(this, 'MyBucket', {
141141
#### [ Python ]
142142

143143
```
144-
cdk.CfnResource(self, 'MyBucket',
144+
cdk.CfnResource(self, 'amzn-s3-demo-bucket',
145145
type="AWS::S3::Bucket",
146146
properties=dict(
147147
# Note the PascalCase here! These are CloudFormation identifiers.
@@ -159,7 +159,7 @@ cdk.CfnResource(self, 'MyBucket',
159159
#### [ Java ]
160160

161161
```
162-
CfnResource.Builder.create(this, "MyBucket")
162+
CfnResource.Builder.create(this, "amzn-s3-demo-bucket")
163163
.type("AWS::S3::Bucket")
164164
.properties(java.util.Map.of( // Map.of requires Java 9 or later
165165
// Note the PascalCase here! These are CloudFormation identifiers
@@ -173,7 +173,7 @@ CfnResource.Builder.create(this, "MyBucket")
173173
#### [ C\# ]
174174

175175
```
176-
new CfnResource(this, "MyBucket", new CfnResourceProps
176+
new CfnResource(this, "amzn-s3-demo-bucket", new CfnResourceProps
177177
{
178178
Type = "AWS::S3::Bucket",
179179
Properties = new Dictionary<string, object>

v2/configure-access-sso-example-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ $ cdk diff --profile my-dev-profile
113113
Stack CdkAppStack
114114
Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)
115115
Resources
116-
[-] AWS::S3::Bucket myBucket myBucket5AF9C99B destroy
116+
[-] AWS::S3::Bucket amzn-s3-demo-bucket amzn-s3-demo-bucket5AF9C99B destroy
117117
118118
Outputs
119119
[-] Output BucketRegion: {"Value":{"Ref":"AWS::Region"}}

v2/configure-env.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export class CdkAppStack extends cdk.Stack {
345345
super(scope, id, props);
346346
347347
// Create the S3 bucket
348-
const bucket = new s3.Bucket(this, 'myBucket', {
348+
const bucket = new s3.Bucket(this, 'amzn-s3-demo-bucket', {
349349
removalPolicy: cdk.RemovalPolicy.DESTROY,
350350
});
351351
@@ -366,7 +366,7 @@ class CdkAppStack extends cdk.Stack {
366366
super(scope, id, props);
367367
368368
// Create the S3 bucket
369-
const bucket = new s3.Bucket(this, 'myBucket', {
369+
const bucket = new s3.Bucket(this, 'amzn-s3-demo-bucket', {
370370
removalPolicy: cdk.RemovalPolicy.DESTROY,
371371
});
372372
@@ -388,7 +388,7 @@ class CdkAppStack(cdk.Stack):
388388
super().__init__(scope, id, **kwargs)
389389
390390
# Create the S3 bucket
391-
bucket = s3.Bucket(self, 'myBucket',
391+
bucket = s3.Bucket(self, 'amzn-s3-demo-bucket',
392392
removal_policy=cdk.RemovalPolicy.DESTROY
393393
)
394394
@@ -408,7 +408,7 @@ public class CdkAppStack extends Stack {
408408
super(scope, id, props);
409409
410410
// Create the S3 bucket
411-
Bucket bucket = Bucket.Builder.create(this, "myBucket")
411+
Bucket bucket = Bucket.Builder.create(this, "amzn-s3-demo-bucket")
412412
.removalPolicy(RemovalPolicy.DESTROY)
413413
.build();
414414
@@ -431,7 +431,7 @@ namespace MyCdkApp
431431
public CdkAppStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
432432
{
433433
// Create the S3 bucket
434-
var bucket = new Bucket(this, "myBucket", new BucketProps
434+
var bucket = new Bucket(this, "amzn-s3-demo-bucket", new BucketProps
435435
{
436436
RemovalPolicy = RemovalPolicy.DESTROY
437437
});
@@ -454,7 +454,7 @@ func NewCdkAppStack(scope constructs.Construct, id string, props *CdkAppStackPro
454454
stack := awscdk.NewStack(scope, &id, &props.StackProps)
455455
456456
// Create the S3 bucket
457-
bucket := awss3.NewBucket(stack, jsii.String("myBucket"), &awss3.BucketProps{
457+
bucket := awss3.NewBucket(stack, jsii.String("amzn-s3-demo-bucket"), &awss3.BucketProps{
458458
RemovalPolicy: awscdk.RemovalPolicy_DESTROY,
459459
})
460460

v2/configure-synth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ new DefaultStackSynthesizer(new DefaultStackSynthesizerProps
597597

598598
To modify the security credentials used to provide permissions during CDK deployments, you can customize synthesis by using `[CliCredentialsStackSynthesizer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CliCredentialsStackSynthesizer.html)`\. This synthesizer works with the default AWS resources that are created during bootstrapping to store assets, such as the Amazon S3 bucket and Amazon ECR repository\. Instead of using the default IAM roles created by the CDK during bootstrapping, it uses the security credentials of the actor initiating deployment\. Therefore, the security credentials of the actor must have valid permissions to perform all deployment actions\. The following diagram illustrates the deployment process when using this synthesizer:
599599

600-
![\[Flowchart of the default AWS CDK deployment process.\]](http://docs.aws.amazon.com/cdk/v2/guide/images/CliCredentialsStackSynthesizer-deploy-process_cdk_flowchart.svg)
600+
![\[\]](http://docs.aws.amazon.com/cdk/v2/guide/images/CliCredentialsStackSynthesizer-deploy-process_cdk_flowchart.svg)
601601

602602
When using `CliCredentialsStackSynthesizer`:
603603
+ By default, CloudFormation performs API calls in your account using the permissions of the actor\. Therefore, the current identity must have permission to make necessary changes to the AWS resources in the CloudFormation stack, along with the permissions to perform necessary CloudFormation operations, such as `CreateStack` or `UpdateStack`\. Deployment capabilities will be limited to the permissions of the actor\.

v2/constructs.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -450,50 +450,50 @@ In this example, we create a `bucket` object using the `CfnBucket` L1 construct:
450450
#### [ TypeScript ]
451451

452452
```
453-
const bucket = new s3.CfnBucket(this, "MyBucket", {
454-
bucketName: "MyBucket"
453+
const bucket = new s3.CfnBucket(this, "amzn-s3-demo-bucket", {
454+
bucketName: "amzn-s3-demo-bucket"
455455
});
456456
```
457457

458458
------
459459
#### [ JavaScript ]
460460

461461
```
462-
const bucket = new s3.CfnBucket(this, "MyBucket", {
463-
bucketName: "MyBucket"
462+
const bucket = new s3.CfnBucket(this, "amzn-s3-demo-bucket", {
463+
bucketName: "amzn-s3-demo-bucket"
464464
});
465465
```
466466

467467
------
468468
#### [ Python ]
469469

470470
```
471-
bucket = s3.CfnBucket(self, "MyBucket", bucket_name="MyBucket")
471+
bucket = s3.CfnBucket(self, "amzn-s3-demo-bucket", bucket_name="amzn-s3-demo-bucket")
472472
```
473473

474474
------
475475
#### [ Java ]
476476

477477
```
478-
CfnBucket bucket = new CfnBucket.Builder().bucketName("MyBucket").build();
478+
CfnBucket bucket = new CfnBucket.Builder().bucketName("amzn-s3-demo-bucket").build();
479479
```
480480

481481
------
482482
#### [ C\# ]
483483

484484
```
485-
var bucket = new CfnBucket(this, "MyBucket", new CfnBucketProps
485+
var bucket = new CfnBucket(this, "amzn-s3-demo-bucket", new CfnBucketProps
486486
{
487-
BucketName= "MyBucket"
487+
BucketName= "amzn-s3-demo-bucket"
488488
});
489489
```
490490

491491
------
492492
#### [ Go ]
493493

494494
```
495-
awss3.NewCfnBucket(stack, jsii.String("MyBucket"), &awss3.CfnBucketProps{
496-
BucketName: jsii.String("MyBucket"),
495+
awss3.NewCfnBucket(stack, jsii.String("amzn-s3-demo-bucket"), &awss3.CfnBucketProps{
496+
BucketName: jsii.String("amzn-s3-demo-bucket"),
497497
})
498498
```
499499

@@ -505,8 +505,8 @@ Construct properties that aren't simple Booleans, strings, numbers, or container
505505
#### [ TypeScript ]
506506

507507
```
508-
const bucket = new s3.CfnBucket(this, "MyBucket", {
509-
bucketName: "MyBucket",
508+
const bucket = new s3.CfnBucket(this, "amzn-s3-demo-bucket", {
509+
bucketName: "amzn-s3-demo-bucket",
510510
corsConfiguration: {
511511
corsRules: [{
512512
allowedOrigins: ["*"],
@@ -520,8 +520,8 @@ const bucket = new s3.CfnBucket(this, "MyBucket", {
520520
#### [ JavaScript ]
521521

522522
```
523-
const bucket = new s3.CfnBucket(this, "MyBucket", {
524-
bucketName: "MyBucket",
523+
const bucket = new s3.CfnBucket(this, "amzn-s3-demo-bucket", {
524+
bucketName: "amzn-s3-demo-bucket",
525525
corsConfiguration: {
526526
corsRules: [{
527527
allowedOrigins: ["*"],
@@ -537,7 +537,7 @@ const bucket = new s3.CfnBucket(this, "MyBucket", {
537537
In Python, these properties are represented by types defined as inner classes of the L1 construct\. For example, the optional property `cors_configuration` of a `CfnBucket` requires a wrapper of type `CfnBucket.CorsConfigurationProperty`\. Here we are defining `cors_configuration` on a `CfnBucket` instance\.
538538

539539
```
540-
bucket = CfnBucket(self, "MyBucket", bucket_name="MyBucket",
540+
bucket = CfnBucket(self, "amzn-s3-demo-bucket", bucket_name="amzn-s3-demo-bucket",
541541
cors_configuration=CfnBucket.CorsConfigurationProperty(
542542
cors_rules=[CfnBucket.CorsRuleProperty(
543543
allowed_origins=["*"],
@@ -553,8 +553,8 @@ bucket = CfnBucket(self, "MyBucket", bucket_name="MyBucket",
553553
In Java, these properties are represented by types defined as inner classes of the L1 construct\. For example, the optional property `corsConfiguration` of a `CfnBucket` requires a wrapper of type `CfnBucket.CorsConfigurationProperty`\. Here we are defining `corsConfiguration` on a `CfnBucket` instance\.
554554

555555
```
556-
CfnBucket bucket = CfnBucket.Builder.create(this, "MyBucket")
557-
.bucketName("MyBucket")
556+
CfnBucket bucket = CfnBucket.Builder.create(this, "amzn-s3-demo-bucket")
557+
.bucketName("amzn-s3-demo-bucket")
558558
.corsConfiguration(new CfnBucket.CorsConfigurationProperty.Builder()
559559
.corsRules(Arrays.asList(new CfnBucket.CorsRuleProperty.Builder()
560560
.allowedOrigins(Arrays.asList("*"))
@@ -570,9 +570,9 @@ CfnBucket bucket = CfnBucket.Builder.create(this, "MyBucket")
570570
In C\#, these properties are represented by types defined as inner classes of the L1 construct\. For example, the optional property `CorsConfiguration` of a `CfnBucket` requires a wrapper of type `CfnBucket.CorsConfigurationProperty`\. Here we are defining `CorsConfiguration` on a `CfnBucket` instance\.
571571

572572
```
573-
var bucket = new CfnBucket(this, "MyBucket", new CfnBucketProps
573+
var bucket = new CfnBucket(this, "amzn-s3-demo-bucket", new CfnBucketProps
574574
{
575-
BucketName = "MyBucket",
575+
BucketName = "amzn-s3-demo-bucket",
576576
CorsConfiguration = new CfnBucket.CorsConfigurationProperty
577577
{
578578
CorsRules = new object[] {
@@ -592,8 +592,8 @@ var bucket = new CfnBucket(this, "MyBucket", new CfnBucketProps
592592
In Go, these types are named using the name of the L1 construct, an underscore, and the property name\. For example, the optional property `CorsConfiguration` of a `CfnBucket` requires a wrapper of type `CfnBucket_CorsConfigurationProperty`\. Here we are defining `CorsConfiguration` on a `CfnBucket` instance\.
593593

594594
```
595-
awss3.NewCfnBucket(stack, jsii.String("MyBucket"), &awss3.CfnBucketProps{
596-
BucketName: jsii.String("MyBucket"),
595+
awss3.NewCfnBucket(stack, jsii.String("amzn-s3-demo-bucket"), &awss3.CfnBucketProps{
596+
BucketName: jsii.String("amzn-s3-demo-bucket"),
597597
CorsConfiguration: &awss3.CfnBucket_CorsConfigurationProperty{
598598
CorsRules: []awss3.CorsRule{
599599
awss3.CorsRule{

v2/deploy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ To deploy your application, we recommend that you use the CDK CLI `cdk deploy` c
150150

151151
When you run `cdk deploy`, the CDK CLI initiates `cdk synth` to prepare for deployment\. The following diagram illustrates the app lifecycle in the context of a deployment:
152152

153-
![\[Flowchart of the AWS CDK app lifecycle.\]](http://docs.aws.amazon.com/cdk/v2/guide/images/app-lifecycle_cdk-flowchart.svg)
153+
![\[\]](http://docs.aws.amazon.com/cdk/v2/guide/images/app-lifecycle_cdk-flowchart.svg)
154154

155155
During deployment, the CDK CLI takes the cloud assembly produced by synthesis and deploys it to an AWS environment\. Assets are uploaded to Amazon S3 and Amazon ECR and the CloudFormation template is submitted to AWS CloudFormation for deployment\.
156156

@@ -162,7 +162,7 @@ By the time the AWS CloudFormation deployment phase starts, your CDK app has alr
162162

163163
Before deployment can be performed, permissions must be established\. The following diagram illustrates the permissions that are used during a default deployment, when using the default bootstrapping process and stack synthesizer:
164164

165-
![\[Flowchart of the default AWS CDK deployment process.\]](http://docs.aws.amazon.com/cdk/v2/guide/images/default-deploy-process_cdk_flowchart.svg)
165+
![\[\]](http://docs.aws.amazon.com/cdk/v2/guide/images/default-deploy-process_cdk_flowchart.svg)
166166

167167
**Actor initiates deployment**
168168
Deployments are initiated by an *actor*, using the CDK CLI\. An actor can either be a person, or a service such as AWS CodePipeline\.

0 commit comments

Comments
 (0)