@aws-cdk/toolkit-lib 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CODE_REGISTRY.md +12 -9
  2. package/build-info.json +2 -2
  3. package/db.json.gz +0 -0
  4. package/lib/actions/bootstrap/index.d.ts +174 -0
  5. package/lib/actions/bootstrap/index.js +94 -0
  6. package/lib/actions/bootstrap/private/helpers.d.ts +5 -0
  7. package/lib/actions/bootstrap/private/helpers.js +23 -0
  8. package/lib/actions/bootstrap/private/index.d.ts +1 -0
  9. package/lib/actions/bootstrap/private/index.js +18 -0
  10. package/lib/actions/destroy/index.d.ts +1 -1
  11. package/lib/actions/destroy/index.js +1 -1
  12. package/lib/actions/index.d.ts +1 -0
  13. package/lib/actions/index.js +2 -1
  14. package/lib/actions/list/index.d.ts +4 -0
  15. package/lib/actions/list/index.js +1 -1
  16. package/lib/api/aws-cdk.d.ts +3 -6
  17. package/lib/api/aws-cdk.js +710 -252
  18. package/lib/api/aws-cdk.js.map +4 -4
  19. package/lib/api/bootstrap/bootstrap-template.yaml +707 -0
  20. package/lib/api/cloud-assembly/context.d.ts +9 -0
  21. package/lib/api/cloud-assembly/context.js +3 -0
  22. package/lib/api/cloud-assembly/private/context-aware-source.js +3 -3
  23. package/lib/api/cloud-assembly/private/prepare-source.d.ts +1 -1
  24. package/lib/api/cloud-assembly/private/prepare-source.js +4 -3
  25. package/lib/api/cloud-assembly/private/source-builder.js +3 -3
  26. package/lib/api/io/index.d.ts +1 -2
  27. package/lib/api/io/index.js +1 -17
  28. package/lib/api/io/private/codes.d.ts +39 -59
  29. package/lib/api/io/private/codes.js +55 -67
  30. package/lib/api/io/private/index.d.ts +0 -1
  31. package/lib/api/io/private/index.js +1 -2
  32. package/lib/api/io/private/level-priority.d.ts +1 -1
  33. package/lib/api/io/private/level-priority.js +1 -1
  34. package/lib/api/io/private/logger.d.ts +3 -12
  35. package/lib/api/io/private/logger.js +1 -22
  36. package/lib/api/io/private/messages.d.ts +7 -3
  37. package/lib/api/io/private/messages.js +1 -2
  38. package/lib/api/io/private/timer.d.ts +2 -2
  39. package/lib/api/io/private/timer.js +13 -13
  40. package/lib/api/shared-private.d.ts +1 -0
  41. package/lib/api/shared-private.js +82 -0
  42. package/lib/api/shared-private.js.map +7 -0
  43. package/lib/api/shared-public.d.ts +130 -1
  44. package/lib/api/shared-public.js.map +1 -1
  45. package/lib/private/util.d.ts +1 -0
  46. package/lib/private/util.js +715 -0
  47. package/lib/private/util.js.map +7 -0
  48. package/lib/toolkit/private/index.d.ts +10 -1
  49. package/lib/toolkit/private/index.js +18 -1
  50. package/lib/toolkit/toolkit.d.ts +7 -11
  51. package/lib/toolkit/toolkit.js +126 -99
  52. package/lib/util/concurrency.d.ts +5 -0
  53. package/lib/util/concurrency.js +11 -0
  54. package/package.json +11 -11
  55. package/lib/api/io/io-host.d.ts +0 -15
  56. package/lib/api/io/io-host.js +0 -3
  57. package/lib/api/io/io-message.d.ts +0 -59
  58. package/lib/api/io/io-message.js +0 -3
  59. package/lib/api/io/private/types.d.ts +0 -25
  60. package/lib/api/io/private/types.js +0 -3
@@ -0,0 +1,707 @@
1
+ Description: This stack includes resources needed to deploy AWS CDK apps into this
2
+ environment
3
+ Parameters:
4
+ TrustedAccounts:
5
+ Description: List of AWS accounts that are trusted to publish assets and deploy
6
+ stacks to this environment
7
+ Default: ''
8
+ Type: CommaDelimitedList
9
+ TrustedAccountsForLookup:
10
+ Description: List of AWS accounts that are trusted to look up values in this
11
+ environment
12
+ Default: ''
13
+ Type: CommaDelimitedList
14
+ CloudFormationExecutionPolicies:
15
+ Description: List of the ManagedPolicy ARN(s) to attach to the CloudFormation
16
+ deployment role
17
+ Default: ''
18
+ Type: CommaDelimitedList
19
+ FileAssetsBucketName:
20
+ Description: The name of the S3 bucket used for file assets
21
+ Default: ''
22
+ Type: String
23
+ FileAssetsBucketKmsKeyId:
24
+ Description: Empty to create a new key (default), 'AWS_MANAGED_KEY' to use a managed
25
+ S3 key, or the ID/ARN of an existing key.
26
+ Default: ''
27
+ Type: String
28
+ ContainerAssetsRepositoryName:
29
+ Description: A user-provided custom name to use for the container assets ECR repository
30
+ Default: ''
31
+ Type: String
32
+ Qualifier:
33
+ Description: An identifier to distinguish multiple bootstrap stacks in the same environment
34
+ Default: hnb659fds
35
+ Type: String
36
+ # "cdk-(qualifier)-image-publishing-role-(account)-(region)" needs to be <= 64 chars
37
+ # account = 12, region <= 14, 10 chars for qualifier and 28 for rest of role name
38
+ AllowedPattern: "[A-Za-z0-9_-]{1,10}"
39
+ ConstraintDescription: Qualifier must be an alphanumeric identifier of at most 10 characters
40
+ PublicAccessBlockConfiguration:
41
+ Description: Whether or not to enable S3 Staging Bucket Public Access Block Configuration
42
+ Default: 'true'
43
+ Type: 'String'
44
+ AllowedValues: ['true', 'false']
45
+ InputPermissionsBoundary:
46
+ Description: Whether or not to use either the CDK supplied or custom permissions boundary
47
+ Default: ''
48
+ Type: 'String'
49
+ UseExamplePermissionsBoundary:
50
+ Default: 'false'
51
+ AllowedValues: [ 'true', 'false' ]
52
+ Type: String
53
+ BootstrapVariant:
54
+ Type: String
55
+ Default: 'AWS CDK: Default Resources'
56
+ Description: Describe the provenance of the resources in this bootstrap
57
+ stack. Change this when you customize the template. To prevent accidents,
58
+ the CDK CLI will not overwrite bootstrap stacks with a different variant.
59
+ Conditions:
60
+ HasTrustedAccounts:
61
+ Fn::Not:
62
+ - Fn::Equals:
63
+ - ''
64
+ - Fn::Join:
65
+ - ''
66
+ - Ref: TrustedAccounts
67
+ HasTrustedAccountsForLookup:
68
+ Fn::Not:
69
+ - Fn::Equals:
70
+ - ''
71
+ - Fn::Join:
72
+ - ''
73
+ - Ref: TrustedAccountsForLookup
74
+ HasCloudFormationExecutionPolicies:
75
+ Fn::Not:
76
+ - Fn::Equals:
77
+ - ''
78
+ - Fn::Join:
79
+ - ''
80
+ - Ref: CloudFormationExecutionPolicies
81
+ HasCustomFileAssetsBucketName:
82
+ Fn::Not:
83
+ - Fn::Equals:
84
+ - ''
85
+ - Ref: FileAssetsBucketName
86
+ CreateNewKey:
87
+ Fn::Equals:
88
+ - ''
89
+ - Ref: FileAssetsBucketKmsKeyId
90
+ UseAwsManagedKey:
91
+ Fn::Equals:
92
+ - 'AWS_MANAGED_KEY'
93
+ - Ref: FileAssetsBucketKmsKeyId
94
+ ShouldCreatePermissionsBoundary:
95
+ Fn::Equals:
96
+ - 'true'
97
+ - Ref: UseExamplePermissionsBoundary
98
+ PermissionsBoundarySet:
99
+ Fn::Not:
100
+ - Fn::Equals:
101
+ - ''
102
+ - Ref: InputPermissionsBoundary
103
+ HasCustomContainerAssetsRepositoryName:
104
+ Fn::Not:
105
+ - Fn::Equals:
106
+ - ''
107
+ - Ref: ContainerAssetsRepositoryName
108
+ UsePublicAccessBlockConfiguration:
109
+ Fn::Equals:
110
+ - 'true'
111
+ - Ref: PublicAccessBlockConfiguration
112
+ Resources:
113
+ FileAssetsBucketEncryptionKey:
114
+ Type: AWS::KMS::Key
115
+ Properties:
116
+ KeyPolicy:
117
+ Statement:
118
+ - Action:
119
+ - kms:Create*
120
+ - kms:Describe*
121
+ - kms:Enable*
122
+ - kms:List*
123
+ - kms:Put*
124
+ - kms:Update*
125
+ - kms:Revoke*
126
+ - kms:Disable*
127
+ - kms:Get*
128
+ - kms:Delete*
129
+ - kms:ScheduleKeyDeletion
130
+ - kms:CancelKeyDeletion
131
+ - kms:GenerateDataKey
132
+ - kms:TagResource
133
+ - kms:UntagResource
134
+ Effect: Allow
135
+ Principal:
136
+ AWS:
137
+ Ref: AWS::AccountId
138
+ Resource: "*"
139
+ - Action:
140
+ - kms:Decrypt
141
+ - kms:DescribeKey
142
+ - kms:Encrypt
143
+ - kms:ReEncrypt*
144
+ - kms:GenerateDataKey*
145
+ Effect: Allow
146
+ Principal:
147
+ # Not actually everyone -- see below for Conditions
148
+ AWS: "*"
149
+ Resource: "*"
150
+ Condition:
151
+ StringEquals:
152
+ # See https://docs.aws.amazon.com/kms/latest/developerguide/policy-conditions.html#conditions-kms-caller-account
153
+ kms:CallerAccount:
154
+ Ref: AWS::AccountId
155
+ kms:ViaService:
156
+ - Fn::Sub: s3.${AWS::Region}.amazonaws.com
157
+ - Action:
158
+ - kms:Decrypt
159
+ - kms:DescribeKey
160
+ - kms:Encrypt
161
+ - kms:ReEncrypt*
162
+ - kms:GenerateDataKey*
163
+ Effect: Allow
164
+ Principal:
165
+ AWS:
166
+ Fn::Sub: "${FilePublishingRole.Arn}"
167
+ Resource: "*"
168
+ Condition: CreateNewKey
169
+ UpdateReplacePolicy: Delete
170
+ DeletionPolicy: Delete
171
+ FileAssetsBucketEncryptionKeyAlias:
172
+ Condition: CreateNewKey
173
+ Type: AWS::KMS::Alias
174
+ Properties:
175
+ AliasName:
176
+ Fn::Sub: "alias/cdk-${Qualifier}-assets-key"
177
+ TargetKeyId:
178
+ Ref: FileAssetsBucketEncryptionKey
179
+ StagingBucket:
180
+ Type: AWS::S3::Bucket
181
+ Properties:
182
+ BucketName:
183
+ Fn::If:
184
+ - HasCustomFileAssetsBucketName
185
+ - Fn::Sub: "${FileAssetsBucketName}"
186
+ - Fn::Sub: cdk-${Qualifier}-assets-${AWS::AccountId}-${AWS::Region}
187
+ AccessControl: Private
188
+ BucketEncryption:
189
+ ServerSideEncryptionConfiguration:
190
+ - ServerSideEncryptionByDefault:
191
+ SSEAlgorithm: aws:kms
192
+ KMSMasterKeyID:
193
+ Fn::If:
194
+ - CreateNewKey
195
+ - Fn::Sub: "${FileAssetsBucketEncryptionKey.Arn}"
196
+ - Fn::If:
197
+ - UseAwsManagedKey
198
+ - Ref: AWS::NoValue
199
+ - Fn::Sub: "${FileAssetsBucketKmsKeyId}"
200
+ PublicAccessBlockConfiguration:
201
+ Fn::If:
202
+ - UsePublicAccessBlockConfiguration
203
+ - BlockPublicAcls: true
204
+ BlockPublicPolicy: true
205
+ IgnorePublicAcls: true
206
+ RestrictPublicBuckets: true
207
+ - Ref: AWS::NoValue
208
+ VersioningConfiguration:
209
+ Status: Enabled
210
+ LifecycleConfiguration:
211
+ Rules:
212
+ # Objects will only be noncurrent if they are deleted via garbage collection.
213
+ - Id: CleanupOldVersions
214
+ Status: Enabled
215
+ NoncurrentVersionExpiration:
216
+ NoncurrentDays: 30
217
+ - Id: AbortIncompleteMultipartUploads
218
+ Status: Enabled
219
+ AbortIncompleteMultipartUpload:
220
+ DaysAfterInitiation: 1
221
+ UpdateReplacePolicy: Retain
222
+ DeletionPolicy: Retain
223
+ StagingBucketPolicy:
224
+ Type: 'AWS::S3::BucketPolicy'
225
+ Properties:
226
+ Bucket: { Ref: 'StagingBucket' }
227
+ PolicyDocument:
228
+ Id: 'AccessControl'
229
+ Version: '2012-10-17'
230
+ Statement:
231
+ - Sid: 'AllowSSLRequestsOnly'
232
+ Action: 's3:*'
233
+ Effect: 'Deny'
234
+ Resource:
235
+ - { 'Fn::Sub': '${StagingBucket.Arn}' }
236
+ - { 'Fn::Sub': '${StagingBucket.Arn}/*' }
237
+ Condition:
238
+ Bool: { 'aws:SecureTransport': 'false' }
239
+ Principal: '*'
240
+ ContainerAssetsRepository:
241
+ Type: AWS::ECR::Repository
242
+ Properties:
243
+ ImageTagMutability: IMMUTABLE
244
+ # Untagged images should never exist but Security Hub wants this rule to exist
245
+ LifecyclePolicy:
246
+ LifecyclePolicyText: |
247
+ {
248
+ "rules": [
249
+ {
250
+ "rulePriority": 1,
251
+ "description": "Untagged images should not exist, but expire any older than one year",
252
+ "selection": {
253
+ "tagStatus": "untagged",
254
+ "countType": "sinceImagePushed",
255
+ "countUnit": "days",
256
+ "countNumber": 365
257
+ },
258
+ "action": { "type": "expire" }
259
+ }
260
+ ]
261
+ }
262
+ RepositoryName:
263
+ Fn::If:
264
+ - HasCustomContainerAssetsRepositoryName
265
+ - Fn::Sub: "${ContainerAssetsRepositoryName}"
266
+ - Fn::Sub: cdk-${Qualifier}-container-assets-${AWS::AccountId}-${AWS::Region}
267
+ RepositoryPolicyText:
268
+ Version: "2012-10-17"
269
+ Statement:
270
+ # Necessary for Lambda container images
271
+ # https://docs.aws.amazon.com/lambda/latest/dg/configuration-images.html#configuration-images-permissions
272
+ - Sid: LambdaECRImageRetrievalPolicy
273
+ Effect: Allow
274
+ Principal: { Service: "lambda.amazonaws.com" }
275
+ Action:
276
+ - ecr:BatchGetImage
277
+ - ecr:GetDownloadUrlForLayer
278
+ Condition:
279
+ StringLike:
280
+ "aws:sourceArn": { "Fn::Sub": "arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:*" }
281
+ # Necessary for EMR Serverless container images
282
+ # https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/application-custom-image.html#access-repo
283
+ - Sid: EmrServerlessImageRetrievalPolicy
284
+ Effect: Allow
285
+ Principal:
286
+ Service: emr-serverless.amazonaws.com
287
+ Action:
288
+ - ecr:BatchGetImage
289
+ - ecr:GetDownloadUrlForLayer
290
+ - ecr:DescribeImages
291
+ Condition:
292
+ StringLike:
293
+ "aws:sourceArn": { "Fn::Sub": "arn:${AWS::Partition}:emr-serverless:${AWS::Region}:${AWS::AccountId}:/applications/*" }
294
+ FilePublishingRole:
295
+ Type: AWS::IAM::Role
296
+ Properties:
297
+ AssumeRolePolicyDocument:
298
+ Statement:
299
+ # allows this role to be assumed with session tags.
300
+ # see https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_permissions-required
301
+ - Action: sts:TagSession
302
+ Effect: Allow
303
+ Principal:
304
+ AWS:
305
+ Ref: AWS::AccountId
306
+ - Action: sts:AssumeRole
307
+ Effect: Allow
308
+ Principal:
309
+ AWS:
310
+ Ref: AWS::AccountId
311
+ - Fn::If:
312
+ - HasTrustedAccounts
313
+ - Action: sts:AssumeRole
314
+ Effect: Allow
315
+ Principal:
316
+ AWS:
317
+ Ref: TrustedAccounts
318
+ - Ref: AWS::NoValue
319
+ RoleName:
320
+ Fn::Sub: cdk-${Qualifier}-file-publishing-role-${AWS::AccountId}-${AWS::Region}
321
+ Tags:
322
+ - Key: aws-cdk:bootstrap-role
323
+ Value: file-publishing
324
+ ImagePublishingRole:
325
+ Type: AWS::IAM::Role
326
+ Properties:
327
+ AssumeRolePolicyDocument:
328
+ Statement:
329
+ # allows this role to be assumed with session tags.
330
+ # see https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_permissions-required
331
+ - Action: sts:TagSession
332
+ Effect: Allow
333
+ Principal:
334
+ AWS:
335
+ Ref: AWS::AccountId
336
+ - Action: sts:AssumeRole
337
+ Effect: Allow
338
+ Principal:
339
+ AWS:
340
+ Ref: AWS::AccountId
341
+ - Fn::If:
342
+ - HasTrustedAccounts
343
+ - Action: sts:AssumeRole
344
+ Effect: Allow
345
+ Principal:
346
+ AWS:
347
+ Ref: TrustedAccounts
348
+ - Ref: AWS::NoValue
349
+ RoleName:
350
+ Fn::Sub: cdk-${Qualifier}-image-publishing-role-${AWS::AccountId}-${AWS::Region}
351
+ Tags:
352
+ - Key: aws-cdk:bootstrap-role
353
+ Value: image-publishing
354
+ LookupRole:
355
+ Type: AWS::IAM::Role
356
+ Properties:
357
+ AssumeRolePolicyDocument:
358
+ Statement:
359
+ # allows this role to be assumed with session tags.
360
+ # see https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_permissions-required
361
+ - Action: sts:TagSession
362
+ Effect: Allow
363
+ Principal:
364
+ AWS:
365
+ Ref: AWS::AccountId
366
+ - Action: sts:AssumeRole
367
+ Effect: Allow
368
+ Principal:
369
+ AWS:
370
+ Ref: AWS::AccountId
371
+ - Fn::If:
372
+ - HasTrustedAccountsForLookup
373
+ - Action: sts:AssumeRole
374
+ Effect: Allow
375
+ Principal:
376
+ AWS:
377
+ Ref: TrustedAccountsForLookup
378
+ - Ref: AWS::NoValue
379
+ - Fn::If:
380
+ - HasTrustedAccounts
381
+ - Action: sts:AssumeRole
382
+ Effect: Allow
383
+ Principal:
384
+ AWS:
385
+ Ref: TrustedAccounts
386
+ - Ref: AWS::NoValue
387
+ RoleName:
388
+ Fn::Sub: cdk-${Qualifier}-lookup-role-${AWS::AccountId}-${AWS::Region}
389
+ ManagedPolicyArns:
390
+ - Fn::Sub: "arn:${AWS::Partition}:iam::aws:policy/ReadOnlyAccess"
391
+ Policies:
392
+ - PolicyDocument:
393
+ Statement:
394
+ - Sid: DontReadSecrets
395
+ Effect: Deny
396
+ Action:
397
+ - kms:Decrypt
398
+ Resource: "*"
399
+ Version: '2012-10-17'
400
+ PolicyName: LookupRolePolicy
401
+ Tags:
402
+ - Key: aws-cdk:bootstrap-role
403
+ Value: lookup
404
+ FilePublishingRoleDefaultPolicy:
405
+ Type: AWS::IAM::Policy
406
+ Properties:
407
+ PolicyDocument:
408
+ Statement:
409
+ - Action:
410
+ - s3:GetObject*
411
+ - s3:GetBucket*
412
+ - s3:GetEncryptionConfiguration
413
+ - s3:List*
414
+ - s3:DeleteObject*
415
+ - s3:PutObject*
416
+ - s3:Abort*
417
+ Resource:
418
+ - Fn::Sub: "${StagingBucket.Arn}"
419
+ - Fn::Sub: "${StagingBucket.Arn}/*"
420
+ Condition:
421
+ StringEquals:
422
+ aws:ResourceAccount:
423
+ - Fn::Sub: ${AWS::AccountId}
424
+ Effect: Allow
425
+ - Action:
426
+ - kms:Decrypt
427
+ - kms:DescribeKey
428
+ - kms:Encrypt
429
+ - kms:ReEncrypt*
430
+ - kms:GenerateDataKey*
431
+ Effect: Allow
432
+ Resource:
433
+ Fn::If:
434
+ - CreateNewKey
435
+ - Fn::Sub: "${FileAssetsBucketEncryptionKey.Arn}"
436
+ - Fn::Sub: arn:${AWS::Partition}:kms:${AWS::Region}:${AWS::AccountId}:key/${FileAssetsBucketKmsKeyId}
437
+ Version: '2012-10-17'
438
+ Roles:
439
+ - Ref: FilePublishingRole
440
+ PolicyName:
441
+ Fn::Sub: cdk-${Qualifier}-file-publishing-role-default-policy-${AWS::AccountId}-${AWS::Region}
442
+ ImagePublishingRoleDefaultPolicy:
443
+ Type: AWS::IAM::Policy
444
+ Properties:
445
+ PolicyDocument:
446
+ Statement:
447
+ - Action:
448
+ - ecr:PutImage
449
+ - ecr:InitiateLayerUpload
450
+ - ecr:UploadLayerPart
451
+ - ecr:CompleteLayerUpload
452
+ - ecr:BatchCheckLayerAvailability
453
+ - ecr:DescribeRepositories
454
+ - ecr:DescribeImages
455
+ - ecr:BatchGetImage
456
+ - ecr:GetDownloadUrlForLayer
457
+ Resource:
458
+ Fn::Sub: "${ContainerAssetsRepository.Arn}"
459
+ Effect: Allow
460
+ - Action:
461
+ - ecr:GetAuthorizationToken
462
+ Resource: "*"
463
+ Effect: Allow
464
+ Version: '2012-10-17'
465
+ Roles:
466
+ - Ref: ImagePublishingRole
467
+ PolicyName:
468
+ Fn::Sub: cdk-${Qualifier}-image-publishing-role-default-policy-${AWS::AccountId}-${AWS::Region}
469
+ DeploymentActionRole:
470
+ Type: AWS::IAM::Role
471
+ Properties:
472
+ AssumeRolePolicyDocument:
473
+ Statement:
474
+ # allows this role to be assumed with session tags.
475
+ # see https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_permissions-required
476
+ - Action: sts:TagSession
477
+ Effect: Allow
478
+ Principal:
479
+ AWS:
480
+ Ref: AWS::AccountId
481
+ - Action: sts:AssumeRole
482
+ Effect: Allow
483
+ Principal:
484
+ AWS:
485
+ Ref: AWS::AccountId
486
+ - Fn::If:
487
+ - HasTrustedAccounts
488
+ - Action: sts:AssumeRole
489
+ Effect: Allow
490
+ Principal:
491
+ AWS:
492
+ Ref: TrustedAccounts
493
+ - Ref: AWS::NoValue
494
+ Policies:
495
+ - PolicyDocument:
496
+ Statement:
497
+ - Sid: CloudFormationPermissions
498
+ Effect: Allow
499
+ Action:
500
+ - cloudformation:CreateChangeSet
501
+ - cloudformation:DeleteChangeSet
502
+ - cloudformation:DescribeChangeSet
503
+ - cloudformation:DescribeStacks
504
+ - cloudformation:ExecuteChangeSet
505
+ - cloudformation:CreateStack
506
+ - cloudformation:UpdateStack
507
+ - cloudformation:RollbackStack
508
+ - cloudformation:ContinueUpdateRollback
509
+ Resource: "*"
510
+ - Sid: PipelineCrossAccountArtifactsBucket
511
+ # Read/write buckets in different accounts. Permissions to buckets in
512
+ # same account are granted by bucket policies.
513
+ #
514
+ # Write permissions necessary to write outputs to the cross-region artifact replication bucket
515
+ # https://aws.amazon.com/premiumsupport/knowledge-center/codepipeline-deploy-cloudformation/.
516
+ Effect: Allow
517
+ Action:
518
+ - s3:GetObject*
519
+ - s3:GetBucket*
520
+ - s3:List*
521
+ - s3:Abort*
522
+ - s3:DeleteObject*
523
+ - s3:PutObject*
524
+ Resource: "*"
525
+ Condition:
526
+ StringNotEquals:
527
+ s3:ResourceAccount:
528
+ Ref: 'AWS::AccountId'
529
+ - Sid: PipelineCrossAccountArtifactsKey
530
+ # Use keys only for the purposes of reading encrypted files from S3.
531
+ Effect: Allow
532
+ Action:
533
+ - kms:Decrypt
534
+ - kms:DescribeKey
535
+ - kms:Encrypt
536
+ - kms:ReEncrypt*
537
+ - kms:GenerateDataKey*
538
+ Resource: "*"
539
+ Condition:
540
+ StringEquals:
541
+ kms:ViaService:
542
+ Fn::Sub: s3.${AWS::Region}.amazonaws.com
543
+ - Action: iam:PassRole
544
+ Resource:
545
+ Fn::Sub: "${CloudFormationExecutionRole.Arn}"
546
+ Effect: Allow
547
+ - Sid: CliPermissions
548
+ Action:
549
+ # Permissions needed by the CLI when doing `cdk deploy`.
550
+ # Our CI/CD does not need DeleteStack,
551
+ # but we also want to use this role from the CLI,
552
+ # and there you can call `cdk destroy`
553
+ - cloudformation:DescribeStackEvents
554
+ - cloudformation:GetTemplate
555
+ - cloudformation:DeleteStack
556
+ - cloudformation:UpdateTerminationProtection
557
+ - sts:GetCallerIdentity
558
+ # `cdk import`
559
+ - cloudformation:GetTemplateSummary
560
+ Resource: "*"
561
+ Effect: Allow
562
+ - Sid: CliStagingBucket
563
+ Effect: Allow
564
+ Action:
565
+ - s3:GetObject*
566
+ - s3:GetBucket*
567
+ - s3:List*
568
+ Resource:
569
+ - Fn::Sub: ${StagingBucket.Arn}
570
+ - Fn::Sub: ${StagingBucket.Arn}/*
571
+ - Sid: ReadVersion
572
+ Effect: Allow
573
+ Action:
574
+ - ssm:GetParameter
575
+ - ssm:GetParameters # CreateChangeSet uses this to evaluate any SSM parameters (like `CdkBootstrapVersion`)
576
+ Resource:
577
+ - Fn::Sub: "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter${CdkBootstrapVersion}"
578
+ Version: '2012-10-17'
579
+ PolicyName: default
580
+ RoleName:
581
+ Fn::Sub: cdk-${Qualifier}-deploy-role-${AWS::AccountId}-${AWS::Region}
582
+ Tags:
583
+ - Key: aws-cdk:bootstrap-role
584
+ Value: deploy
585
+ CloudFormationExecutionRole:
586
+ Type: AWS::IAM::Role
587
+ Properties:
588
+ AssumeRolePolicyDocument:
589
+ Statement:
590
+ - Action: sts:AssumeRole
591
+ Effect: Allow
592
+ Principal:
593
+ Service: cloudformation.amazonaws.com
594
+ Version: '2012-10-17'
595
+ ManagedPolicyArns:
596
+ Fn::If:
597
+ - HasCloudFormationExecutionPolicies
598
+ - Ref: CloudFormationExecutionPolicies
599
+ - Fn::If:
600
+ - HasTrustedAccounts
601
+ # The CLI will prevent this case from occurring
602
+ - Ref: AWS::NoValue
603
+ # The CLI will advertise that we picked this implicitly
604
+ - - Fn::Sub: "arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess"
605
+ RoleName:
606
+ Fn::Sub: cdk-${Qualifier}-cfn-exec-role-${AWS::AccountId}-${AWS::Region}
607
+ PermissionsBoundary:
608
+ Fn::If:
609
+ - PermissionsBoundarySet
610
+ - Fn::Sub: 'arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/${InputPermissionsBoundary}'
611
+ - Ref: AWS::NoValue
612
+ CdkBoostrapPermissionsBoundaryPolicy:
613
+ # Edit the template prior to boostrap in order to have this example policy created
614
+ Condition: ShouldCreatePermissionsBoundary
615
+ Type: AWS::IAM::ManagedPolicy
616
+ Properties:
617
+ PolicyDocument:
618
+ Statement:
619
+ # If permission boundaries do not have an explicit `allow`, then the effect is `deny`
620
+ - Sid: ExplicitAllowAll
621
+ Action:
622
+ - "*"
623
+ Effect: Allow
624
+ Resource: "*"
625
+ # Default permissions to prevent privilege escalation
626
+ - Sid: DenyAccessIfRequiredPermBoundaryIsNotBeingApplied
627
+ Action:
628
+ - iam:CreateUser
629
+ - iam:CreateRole
630
+ - iam:PutRolePermissionsBoundary
631
+ - iam:PutUserPermissionsBoundary
632
+ Condition:
633
+ StringNotEquals:
634
+ iam:PermissionsBoundary:
635
+ Fn::Sub: arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/cdk-${Qualifier}-permissions-boundary-${AWS::AccountId}-${AWS::Region}
636
+ Effect: Deny
637
+ Resource: "*"
638
+ # Forbid the policy itself being edited
639
+ - Sid: DenyPermBoundaryIAMPolicyAlteration
640
+ Action:
641
+ - iam:CreatePolicyVersion
642
+ - iam:DeletePolicy
643
+ - iam:DeletePolicyVersion
644
+ - iam:SetDefaultPolicyVersion
645
+ Effect: Deny
646
+ Resource:
647
+ Fn::Sub: arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/cdk-${Qualifier}-permissions-boundary-${AWS::AccountId}-${AWS::Region}
648
+ # Forbid removing the permissions boundary from any user or role that has it associated
649
+ - Sid: DenyRemovalOfPermBoundaryFromAnyUserOrRole
650
+ Action:
651
+ - iam:DeleteUserPermissionsBoundary
652
+ - iam:DeleteRolePermissionsBoundary
653
+ Effect: Deny
654
+ Resource: "*"
655
+ # Add your specific organizational security policy here
656
+ # Uncomment the example to deny access to AWS Config
657
+ #- Sid: OrganizationalSecurityPolicy
658
+ # Action:
659
+ # - "config:*"
660
+ # Effect: Deny
661
+ # Resource: "*"
662
+ Version: "2012-10-17"
663
+ Description: "Bootstrap Permission Boundary"
664
+ ManagedPolicyName:
665
+ Fn::Sub: cdk-${Qualifier}-permissions-boundary-${AWS::AccountId}-${AWS::Region}
666
+ Path: /
667
+ # The SSM parameter is used in pipeline-deployed templates to verify the version
668
+ # of the bootstrap resources.
669
+ CdkBootstrapVersion:
670
+ Type: AWS::SSM::Parameter
671
+ Properties:
672
+ Type: String
673
+ Name:
674
+ Fn::Sub: '/cdk-bootstrap/${Qualifier}/version'
675
+ Value: '27'
676
+ Outputs:
677
+ BucketName:
678
+ Description: The name of the S3 bucket owned by the CDK toolkit stack
679
+ Value:
680
+ Fn::Sub: "${StagingBucket}"
681
+ BucketDomainName:
682
+ Description: The domain name of the S3 bucket owned by the CDK toolkit stack
683
+ Value:
684
+ Fn::Sub: "${StagingBucket.RegionalDomainName}"
685
+ # @deprecated - This Export can be removed at some future point in time.
686
+ # We can't do it today because if there are stacks that use it, the bootstrap
687
+ # stack cannot be updated. Not used anymore by apps >= 1.60.0
688
+ FileAssetKeyArn:
689
+ Description: The ARN of the KMS key used to encrypt the asset bucket (deprecated)
690
+ Value:
691
+ Fn::If:
692
+ - CreateNewKey
693
+ - Fn::Sub: "${FileAssetsBucketEncryptionKey.Arn}"
694
+ - Fn::Sub: "${FileAssetsBucketKmsKeyId}"
695
+ Export:
696
+ Name:
697
+ Fn::Sub: CdkBootstrap-${Qualifier}-FileAssetKeyArn
698
+ ImageRepositoryName:
699
+ Description: The name of the ECR repository which hosts docker image assets
700
+ Value:
701
+ Fn::Sub: "${ContainerAssetsRepository}"
702
+ # The Output is used by the CLI to verify the version of the bootstrap resources.
703
+ BootstrapVersion:
704
+ Description: The version of the bootstrap resources that are currently mastered
705
+ in this stack
706
+ Value:
707
+ Fn::GetAtt: [CdkBootstrapVersion, Value]