@gradientedge/cdk-utils 8.118.0 → 8.119.0

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 (148) hide show
  1. package/app/api-destined-function/package.json +1 -1
  2. package/dist/src/lib/common/construct.d.ts +32 -32
  3. package/dist/src/lib/common/construct.js +36 -59
  4. package/dist/src/lib/common/stack.d.ts +8 -7
  5. package/dist/src/lib/common/stack.js +17 -37
  6. package/dist/src/lib/common/types.d.ts +2 -2
  7. package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +22 -22
  8. package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +9 -9
  9. package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +3 -3
  10. package/dist/src/lib/construct/api-to-eventbridge-target/main.js +37 -60
  11. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +9 -9
  12. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +3 -3
  13. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +40 -63
  14. package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +23 -23
  15. package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +2 -2
  16. package/dist/src/lib/construct/api-to-lambda-target/main.js +15 -38
  17. package/dist/src/lib/construct/application-configuration/main.d.ts +7 -7
  18. package/dist/src/lib/construct/application-configuration/main.js +17 -41
  19. package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +17 -17
  20. package/dist/src/lib/construct/graphql-api-lambda/main.js +6 -29
  21. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +5 -5
  22. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +7 -7
  23. package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +16 -16
  24. package/dist/src/lib/construct/lambda-with-iam-access/main.js +8 -31
  25. package/dist/src/lib/construct/lambda-with-iam-access/types.d.ts +4 -4
  26. package/dist/src/lib/construct/rest-api-lambda/main.d.ts +16 -16
  27. package/dist/src/lib/construct/rest-api-lambda/main.js +5 -28
  28. package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +5 -5
  29. package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +9 -32
  30. package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +38 -39
  31. package/dist/src/lib/construct/site-with-ecs-backend/main.js +33 -54
  32. package/dist/src/lib/construct/static-asset-deployment/main.d.ts +4 -4
  33. package/dist/src/lib/construct/static-asset-deployment/main.js +3 -26
  34. package/dist/src/lib/construct/static-site/main.d.ts +15 -15
  35. package/dist/src/lib/construct/static-site/main.js +4 -27
  36. package/dist/src/lib/services/aws/api-gateway/main.d.ts +10 -10
  37. package/dist/src/lib/services/aws/api-gateway/main.js +21 -44
  38. package/dist/src/lib/services/aws/api-gateway/types.d.ts +2 -2
  39. package/dist/src/lib/services/aws/appconfig/main.d.ts +7 -7
  40. package/dist/src/lib/services/aws/appconfig/main.js +14 -37
  41. package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -5
  42. package/dist/src/lib/services/aws/certificate-manager/main.js +10 -33
  43. package/dist/src/lib/services/aws/certificate-manager/types.d.ts +2 -2
  44. package/dist/src/lib/services/aws/cloudfront/main.d.ts +18 -18
  45. package/dist/src/lib/services/aws/cloudfront/main.js +46 -45
  46. package/dist/src/lib/services/aws/cloudfront/types.d.ts +2 -3
  47. package/dist/src/lib/services/aws/cloudtrail/main.d.ts +5 -5
  48. package/dist/src/lib/services/aws/cloudtrail/main.js +5 -28
  49. package/dist/src/lib/services/aws/codebuild/main.d.ts +3 -3
  50. package/dist/src/lib/services/aws/codebuild/main.js +7 -30
  51. package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -3
  52. package/dist/src/lib/services/aws/dynamodb/main.js +8 -31
  53. package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +2 -2
  54. package/dist/src/lib/services/aws/elastic-container-registry/main.js +4 -27
  55. package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +10 -10
  56. package/dist/src/lib/services/aws/elastic-container-service/main.js +27 -50
  57. package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +4 -4
  58. package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +3 -3
  59. package/dist/src/lib/services/aws/elastic-file-system/main.js +12 -35
  60. package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +4 -4
  61. package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -31
  62. package/dist/src/lib/services/aws/elasticache/main.d.ts +4 -4
  63. package/dist/src/lib/services/aws/elasticache/main.js +10 -33
  64. package/dist/src/lib/services/aws/eventbridge/main.d.ts +13 -13
  65. package/dist/src/lib/services/aws/eventbridge/main.js +26 -49
  66. package/dist/src/lib/services/aws/eventbridge/target.d.ts +10 -10
  67. package/dist/src/lib/services/aws/eventbridge/target.js +6 -29
  68. package/dist/src/lib/services/aws/evidently/main.d.ts +7 -7
  69. package/dist/src/lib/services/aws/evidently/main.js +18 -41
  70. package/dist/src/lib/services/aws/identity-access-management/main.d.ts +48 -49
  71. package/dist/src/lib/services/aws/identity-access-management/main.js +110 -133
  72. package/dist/src/lib/services/aws/key-management-service/main.d.ts +2 -2
  73. package/dist/src/lib/services/aws/key-management-service/main.js +5 -28
  74. package/dist/src/lib/services/aws/lambda/main.d.ts +11 -13
  75. package/dist/src/lib/services/aws/lambda/main.js +31 -58
  76. package/dist/src/lib/services/aws/route53/main.d.ts +9 -9
  77. package/dist/src/lib/services/aws/route53/main.js +21 -44
  78. package/dist/src/lib/services/aws/secrets-manager/main.d.ts +5 -6
  79. package/dist/src/lib/services/aws/secrets-manager/main.js +10 -33
  80. package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +4 -4
  81. package/dist/src/lib/services/aws/simple-notification-service/main.js +11 -34
  82. package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +6 -7
  83. package/dist/src/lib/services/aws/simple-queue-service/main.js +15 -38
  84. package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +10 -11
  85. package/dist/src/lib/services/aws/simple-storage-service/main.js +31 -54
  86. package/dist/src/lib/services/aws/step-function/main.d.ts +31 -32
  87. package/dist/src/lib/services/aws/step-function/main.js +33 -57
  88. package/dist/src/lib/services/aws/systems-manager/main.d.ts +4 -4
  89. package/dist/src/lib/services/aws/systems-manager/main.js +10 -33
  90. package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +5 -6
  91. package/dist/src/lib/services/aws/virtual-private-cloud/main.js +14 -37
  92. package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +3 -3
  93. package/dist/src/lib/services/aws/web-application-firewall/main.js +8 -31
  94. package/dist/src/lib/utils/aws/index.d.ts +6 -3
  95. package/dist/src/lib/utils/aws/index.js +9 -26
  96. package/package.json +15 -15
  97. package/src/lib/common/construct.ts +97 -67
  98. package/src/lib/common/stack.ts +12 -12
  99. package/src/lib/common/types.ts +2 -2
  100. package/src/lib/construct/api-to-eventbridge-target/api.ts +31 -22
  101. package/src/lib/construct/api-to-eventbridge-target/event.ts +9 -9
  102. package/src/lib/construct/api-to-eventbridge-target/main.ts +56 -41
  103. package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +9 -9
  104. package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +62 -47
  105. package/src/lib/construct/api-to-lambda-target/api.ts +33 -23
  106. package/src/lib/construct/api-to-lambda-target/main.ts +24 -18
  107. package/src/lib/construct/application-configuration/main.ts +31 -24
  108. package/src/lib/construct/graphql-api-lambda/main.ts +22 -22
  109. package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +13 -13
  110. package/src/lib/construct/lambda-with-iam-access/main.ts +25 -25
  111. package/src/lib/construct/lambda-with-iam-access/types.ts +4 -4
  112. package/src/lib/construct/rest-api-lambda/main.ts +21 -21
  113. package/src/lib/construct/rest-api-lambda-with-cache/main.ts +14 -14
  114. package/src/lib/construct/site-with-ecs-backend/main.ts +79 -60
  115. package/src/lib/construct/static-asset-deployment/main.ts +6 -6
  116. package/src/lib/construct/static-site/main.ts +23 -17
  117. package/src/lib/services/aws/api-gateway/main.ts +42 -36
  118. package/src/lib/services/aws/api-gateway/types.ts +2 -2
  119. package/src/lib/services/aws/appconfig/main.ts +19 -19
  120. package/src/lib/services/aws/certificate-manager/main.ts +14 -14
  121. package/src/lib/services/aws/certificate-manager/types.ts +2 -2
  122. package/src/lib/services/aws/cloudfront/main.ts +88 -74
  123. package/src/lib/services/aws/cloudfront/types.ts +6 -3
  124. package/src/lib/services/aws/cloudtrail/main.ts +11 -11
  125. package/src/lib/services/aws/codebuild/main.ts +7 -7
  126. package/src/lib/services/aws/dynamodb/main.ts +8 -8
  127. package/src/lib/services/aws/elastic-container-registry/main.ts +4 -4
  128. package/src/lib/services/aws/elastic-container-service/main.ts +48 -37
  129. package/src/lib/services/aws/elastic-container-service/types.ts +4 -4
  130. package/src/lib/services/aws/elastic-file-system/main.ts +16 -16
  131. package/src/lib/services/aws/elastic-kubernetes-service/main.ts +11 -11
  132. package/src/lib/services/aws/elasticache/main.ts +10 -10
  133. package/src/lib/services/aws/eventbridge/main.ts +37 -37
  134. package/src/lib/services/aws/eventbridge/target.ts +14 -14
  135. package/src/lib/services/aws/evidently/main.ts +18 -18
  136. package/src/lib/services/aws/identity-access-management/main.ts +142 -134
  137. package/src/lib/services/aws/key-management-service/main.ts +5 -5
  138. package/src/lib/services/aws/lambda/main.ts +65 -59
  139. package/src/lib/services/aws/route53/main.ts +31 -31
  140. package/src/lib/services/aws/secrets-manager/main.ts +11 -15
  141. package/src/lib/services/aws/simple-notification-service/main.ts +13 -13
  142. package/src/lib/services/aws/simple-queue-service/main.ts +18 -18
  143. package/src/lib/services/aws/simple-storage-service/main.ts +40 -40
  144. package/src/lib/services/aws/step-function/main.ts +77 -65
  145. package/src/lib/services/aws/systems-manager/main.ts +17 -12
  146. package/src/lib/services/aws/virtual-private-cloud/main.ts +16 -16
  147. package/src/lib/services/aws/web-application-firewall/main.ts +8 -8
  148. package/src/lib/utils/aws/index.ts +8 -5
@@ -1,22 +1,30 @@
1
- import * as cdk from 'aws-cdk-lib'
2
- import * as ecs from 'aws-cdk-lib/aws-ecs'
3
- import * as events from 'aws-cdk-lib/aws-events'
4
- import * as iam from 'aws-cdk-lib/aws-iam'
5
- import * as logs from 'aws-cdk-lib/aws-logs'
6
- import * as s3 from 'aws-cdk-lib/aws-s3'
7
- import * as sqs from 'aws-cdk-lib/aws-sqs'
8
- import * as utils from '../../../utils'
1
+ import { Stack } from 'aws-cdk-lib'
2
+ import { ICluster, ITaskDefinition } from 'aws-cdk-lib/aws-ecs'
3
+ import { IRule } from 'aws-cdk-lib/aws-events'
4
+ import {
5
+ CfnRole,
6
+ Effect,
7
+ ManagedPolicy,
8
+ PolicyDocument,
9
+ PolicyStatement,
10
+ Role,
11
+ ServicePrincipal,
12
+ } from 'aws-cdk-lib/aws-iam'
13
+ import { CfnLogGroup } from 'aws-cdk-lib/aws-logs'
14
+ import { IBucket } from 'aws-cdk-lib/aws-s3'
15
+ import { Queue } from 'aws-cdk-lib/aws-sqs'
9
16
  import { CommonConstruct } from '../../../common'
17
+ import { createCfnOutput } from '../../../utils'
10
18
 
11
19
  /**
12
- * @classdesc Provides operations on AWS IAM.
20
+ * @classdesc Provides operations on AWS
13
21
  * - A new instance of this class is injected into {@link CommonConstruct} constructor.
14
22
  * - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
15
23
  * @example
16
24
  * import { CommonConstruct } from '@gradientedge/cdk-utils'
17
25
  *
18
26
  * class CustomConstruct extends CommonConstruct {
19
- * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
27
+ * constructor(parent: Construct, id: string, props: common.CommonStackProps) {
20
28
  * super(parent, id, props)
21
29
  * this.props = props
22
30
  * this.iamManager.createRoleForEcsEvent('MyEcsRole', this, cluster, task)
@@ -31,11 +39,11 @@ export class IamManager {
31
39
  * @param resourceArns list of ARNs to allow access to
32
40
  */
33
41
  public statementForReadSecrets(scope: CommonConstruct, resourceArns?: string[]) {
34
- return new iam.PolicyStatement({
42
+ return new PolicyStatement({
35
43
  actions: ['secretsmanager:GetSecretValue'],
36
- effect: iam.Effect.ALLOW,
44
+ effect: Effect.ALLOW,
37
45
  resources: resourceArns ?? [
38
- `arn:aws:secretsmanager:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:secret:*`,
46
+ `arn:aws:secretsmanager:${Stack.of(scope).region}:${Stack.of(scope).account}:secret:*`,
39
47
  ],
40
48
  })
41
49
  }
@@ -45,21 +53,21 @@ export class IamManager {
45
53
  * @param resourceArns list of ARNs to allow access to
46
54
  */
47
55
  public statementForPutEvents(resourceArns?: string[]) {
48
- return new iam.PolicyStatement({
56
+ return new PolicyStatement({
49
57
  actions: ['events:PutEvents'],
50
- effect: iam.Effect.ALLOW,
58
+ effect: Effect.ALLOW,
51
59
  resources: resourceArns ?? ['*'],
52
60
  })
53
61
  }
54
62
 
55
63
  /**
56
- * @summary Method to create iam statement to start stepfunction execution
64
+ * @summary Method to create iam statement to start step function execution
57
65
  * @param resourceArns list of ARNs to allow access to
58
66
  */
59
67
  public statementForStartExecution(resourceArns?: string[]) {
60
- return new iam.PolicyStatement({
68
+ return new PolicyStatement({
61
69
  actions: ['states:StartExecution'],
62
- effect: iam.Effect.ALLOW,
70
+ effect: Effect.ALLOW,
63
71
  resources: resourceArns ?? ['*'],
64
72
  })
65
73
  }
@@ -69,9 +77,9 @@ export class IamManager {
69
77
  * @param resourceArns list of ARNs to allow access to
70
78
  */
71
79
  public statementForPollQueue(resourceArns?: string[]) {
72
- return new iam.PolicyStatement({
80
+ return new PolicyStatement({
73
81
  actions: ['sqs:ReceiveMessage', 'sqs:DeleteMessage', 'sqs:GetQueueAttributes'],
74
- effect: iam.Effect.ALLOW,
82
+ effect: Effect.ALLOW,
75
83
  resources: resourceArns ?? ['*'],
76
84
  })
77
85
  }
@@ -81,9 +89,9 @@ export class IamManager {
81
89
  * @param resourceArns list of ARNs to allow access to
82
90
  */
83
91
  public statementForInvokeLambda(resourceArns?: string[]) {
84
- return new iam.PolicyStatement({
92
+ return new PolicyStatement({
85
93
  actions: ['lambda:InvokeFunction'],
86
- effect: iam.Effect.ALLOW,
94
+ effect: Effect.ALLOW,
87
95
  resources: resourceArns ?? ['*'],
88
96
  })
89
97
  }
@@ -93,7 +101,7 @@ export class IamManager {
93
101
  * @param resourceArns list of ARNs to allow access to
94
102
  */
95
103
  public statementForReadAnyAppConfig(resourceArns?: string[]) {
96
- return new iam.PolicyStatement({
104
+ return new PolicyStatement({
97
105
  actions: [
98
106
  'ssm:GetDocument',
99
107
  'ssm:ListDocuments',
@@ -108,7 +116,7 @@ export class IamManager {
108
116
  'appconfig:GetConfiguration',
109
117
  'appconfig:ListDeployments',
110
118
  ],
111
- effect: iam.Effect.ALLOW,
119
+ effect: Effect.ALLOW,
112
120
  resources: resourceArns ?? ['*'],
113
121
  })
114
122
  }
@@ -118,9 +126,9 @@ export class IamManager {
118
126
  * @param resourceArns list of ARNs to allow access to
119
127
  */
120
128
  public statementForAppConfigExecution(resourceArns?: string[]) {
121
- return new iam.PolicyStatement({
129
+ return new PolicyStatement({
122
130
  actions: ['appconfig:GetLatestConfiguration', 'appconfig:StartConfigurationSession'],
123
- effect: iam.Effect.ALLOW,
131
+ effect: Effect.ALLOW,
124
132
  resources: resourceArns ?? ['*'],
125
133
  })
126
134
  }
@@ -130,9 +138,9 @@ export class IamManager {
130
138
  * @param resourceArns list of ARNs to allow access to
131
139
  */
132
140
  public statementForPutXrayTelemetry(resourceArns?: string[]) {
133
- return new iam.PolicyStatement({
141
+ return new PolicyStatement({
134
142
  actions: ['xray:PutTraceSegments', 'xray:PutTelemetryRecords'],
135
- effect: iam.Effect.ALLOW,
143
+ effect: Effect.ALLOW,
136
144
  resources: resourceArns ?? ['*'],
137
145
  })
138
146
  }
@@ -142,9 +150,9 @@ export class IamManager {
142
150
  * @param resourceArns list of ARNs to allow access to
143
151
  */
144
152
  public statementForDecryptKms(resourceArns?: string[]) {
145
- return new iam.PolicyStatement({
153
+ return new PolicyStatement({
146
154
  actions: ['kms:Decrypt'],
147
- effect: iam.Effect.ALLOW,
155
+ effect: Effect.ALLOW,
148
156
  resources: resourceArns ?? ['*'],
149
157
  })
150
158
  }
@@ -154,10 +162,10 @@ export class IamManager {
154
162
  * @param scope scope in which this resource is defined
155
163
  * @param bucket
156
164
  */
157
- public statementForListBucket(scope: CommonConstruct, bucket: s3.IBucket) {
158
- return new iam.PolicyStatement({
165
+ public statementForListBucket(scope: CommonConstruct, bucket: IBucket) {
166
+ return new PolicyStatement({
159
167
  actions: ['s3:ListBucket'],
160
- effect: iam.Effect.ALLOW,
168
+ effect: Effect.ALLOW,
161
169
  resources: [bucket.bucketArn],
162
170
  })
163
171
  }
@@ -167,9 +175,9 @@ export class IamManager {
167
175
  * @param resourceArns list of ARNs to allow access to
168
176
  */
169
177
  public statementForListAllMyBuckets(resourceArns?: string[]) {
170
- return new iam.PolicyStatement({
178
+ return new PolicyStatement({
171
179
  actions: ['s3:ListAllMyBuckets'],
172
- effect: iam.Effect.ALLOW,
180
+ effect: Effect.ALLOW,
173
181
  resources: resourceArns ?? ['*'],
174
182
  })
175
183
  }
@@ -180,10 +188,10 @@ export class IamManager {
180
188
  * @param bucket
181
189
  * @param resourceArns list of ARNs to allow access to
182
190
  */
183
- public statementForGetAnyS3Objects(scope: CommonConstruct, bucket: s3.IBucket, resourceArns?: string[]) {
184
- return new iam.PolicyStatement({
191
+ public statementForGetAnyS3Objects(scope: CommonConstruct, bucket: IBucket, resourceArns?: string[]) {
192
+ return new PolicyStatement({
185
193
  actions: ['s3:GetObject', 's3:GetObjectAcl'],
186
- effect: iam.Effect.ALLOW,
194
+ effect: Effect.ALLOW,
187
195
  resources: resourceArns ?? [bucket.arnForObjects(`*`)],
188
196
  })
189
197
  }
@@ -194,10 +202,10 @@ export class IamManager {
194
202
  * @param bucket
195
203
  * @param resourceArns list of ARNs to allow access to
196
204
  */
197
- public statementForDeleteAnyS3Objects(scope: CommonConstruct, bucket: s3.IBucket, resourceArns?: string[]) {
198
- return new iam.PolicyStatement({
205
+ public statementForDeleteAnyS3Objects(scope: CommonConstruct, bucket: IBucket, resourceArns?: string[]) {
206
+ return new PolicyStatement({
199
207
  actions: ['s3:DeleteObject'],
200
- effect: iam.Effect.ALLOW,
208
+ effect: Effect.ALLOW,
201
209
  resources: resourceArns ?? [bucket.arnForObjects(`*`)],
202
210
  })
203
211
  }
@@ -208,10 +216,10 @@ export class IamManager {
208
216
  * @param bucket
209
217
  * @param resourceArns list of ARNs to allow access to
210
218
  */
211
- public statementForPutAnyS3Objects(scope: CommonConstruct, bucket: s3.IBucket, resourceArns?: string[]) {
212
- return new iam.PolicyStatement({
219
+ public statementForPutAnyS3Objects(scope: CommonConstruct, bucket: IBucket, resourceArns?: string[]) {
220
+ return new PolicyStatement({
213
221
  actions: ['s3:PutObject', 's3:PutObjectAcl'],
214
- effect: iam.Effect.ALLOW,
222
+ effect: Effect.ALLOW,
215
223
  resources: resourceArns ?? [bucket.arnForObjects(`*`)],
216
224
  })
217
225
  }
@@ -221,9 +229,9 @@ export class IamManager {
221
229
  * @param resourceArns list of ARNs to allow access to
222
230
  */
223
231
  public statementForPassRole(resourceArns?: string[]) {
224
- return new iam.PolicyStatement({
232
+ return new PolicyStatement({
225
233
  actions: ['iam:PassRole'],
226
- effect: iam.Effect.ALLOW,
234
+ effect: Effect.ALLOW,
227
235
  resources: resourceArns ?? ['*'],
228
236
  })
229
237
  }
@@ -233,9 +241,9 @@ export class IamManager {
233
241
  * @param resourceArns list of ARNs to allow access to
234
242
  */
235
243
  public statementForCloudfrontInvalidation(resourceArns?: string[]) {
236
- return new iam.PolicyStatement({
244
+ return new PolicyStatement({
237
245
  actions: ['cloudfront:GetInvalidation', 'cloudfront:CreateInvalidation'],
238
- effect: iam.Effect.ALLOW,
246
+ effect: Effect.ALLOW,
239
247
  resources: resourceArns ?? ['*'],
240
248
  })
241
249
  }
@@ -245,9 +253,9 @@ export class IamManager {
245
253
  * @param resourceArns list of ARNs to allow access to
246
254
  */
247
255
  public statementForWriteEfs(resourceArns?: string[]) {
248
- return new iam.PolicyStatement({
256
+ return new PolicyStatement({
249
257
  actions: ['elasticfilesystem:*'],
250
- effect: iam.Effect.ALLOW,
258
+ effect: Effect.ALLOW,
251
259
  resources: resourceArns ?? ['*'],
252
260
  })
253
261
  }
@@ -257,19 +265,19 @@ export class IamManager {
257
265
  * @param resourceArns list of ARNs to allow access to
258
266
  */
259
267
  public policyForCloudfrontInvalidation(resourceArns?: string[]) {
260
- return new iam.PolicyDocument({
268
+ return new PolicyDocument({
261
269
  statements: [
262
270
  this.statementForCreateAnyLogStream(),
263
271
  this.statementForPutAnyLogEvent(),
264
272
  this.statementForCloudfrontInvalidation(),
265
- new iam.PolicyStatement({
273
+ new PolicyStatement({
266
274
  actions: [
267
275
  'ecr:GetDownloadUrlForLayer',
268
276
  'ecr:BatchGetImage',
269
277
  'ecr:BatchCheckLayerAvailability',
270
278
  'ecr:GetAuthorizationToken',
271
279
  ],
272
- effect: iam.Effect.ALLOW,
280
+ effect: Effect.ALLOW,
273
281
  resources: resourceArns ?? ['*'],
274
282
  }),
275
283
  ],
@@ -282,8 +290,8 @@ export class IamManager {
282
290
  * @param scope scope in which this resource is defined
283
291
  */
284
292
  public roleForCloudfrontInvalidation(id: string, scope: CommonConstruct) {
285
- return new iam.Role(scope, `${id}-install-deps-project-role`, {
286
- assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com'),
293
+ return new Role(scope, `${id}-install-deps-project-role`, {
294
+ assumedBy: new ServicePrincipal('codebuild.amazonaws.com'),
287
295
  inlinePolicies: {
288
296
  codeBuildPolicy: this.policyForCloudfrontInvalidation(),
289
297
  },
@@ -295,10 +303,10 @@ export class IamManager {
295
303
  * @param scope scope in which this resource is defined
296
304
  * @param servicePrincipals
297
305
  */
298
- public statementForAssumeRole(scope: CommonConstruct, servicePrincipals: iam.ServicePrincipal[]) {
299
- return new iam.PolicyStatement({
306
+ public statementForAssumeRole(scope: CommonConstruct, servicePrincipals: ServicePrincipal[]) {
307
+ return new PolicyStatement({
300
308
  actions: ['sts:AssumeRole'],
301
- effect: iam.Effect.ALLOW,
309
+ effect: Effect.ALLOW,
302
310
  principals: servicePrincipals,
303
311
  })
304
312
  }
@@ -308,10 +316,10 @@ export class IamManager {
308
316
  * @param resourceArns list of ARNs to allow access to
309
317
  */
310
318
  public statementForEcsPassRole(resourceArns?: string[]) {
311
- return new iam.PolicyStatement({
319
+ return new PolicyStatement({
312
320
  actions: ['iam:PassRole'],
313
321
  conditions: { StringLike: { 'iam:PassedToService': 'ecs-tasks.amazonaws.com' } },
314
- effect: iam.Effect.ALLOW,
322
+ effect: Effect.ALLOW,
315
323
  resources: resourceArns ?? ['*'],
316
324
  })
317
325
  }
@@ -322,11 +330,11 @@ export class IamManager {
322
330
  * @param cluster
323
331
  * @param task
324
332
  */
325
- public statementForRunEcsTask(scope: CommonConstruct, cluster: ecs.ICluster, task: ecs.ITaskDefinition) {
326
- return new iam.PolicyStatement({
333
+ public statementForRunEcsTask(scope: CommonConstruct, cluster: ICluster, task: ITaskDefinition) {
334
+ return new PolicyStatement({
327
335
  actions: ['ecs:RunTask'],
328
336
  conditions: { ArnLike: { 'ecs:cluster': cluster.clusterArn } },
329
- effect: iam.Effect.ALLOW,
337
+ effect: Effect.ALLOW,
330
338
  resources: [task.taskDefinitionArn],
331
339
  })
332
340
  }
@@ -336,14 +344,14 @@ export class IamManager {
336
344
  * @param scope scope in which this resource is defined
337
345
  * @param logGroup
338
346
  */
339
- public statementForCreateLogStream(scope: CommonConstruct, logGroup: logs.CfnLogGroup) {
340
- return new iam.PolicyStatement({
347
+ public statementForCreateLogStream(scope: CommonConstruct, logGroup: CfnLogGroup) {
348
+ return new PolicyStatement({
341
349
  actions: ['logs:CreateLogStream'],
342
- effect: iam.Effect.ALLOW,
350
+ effect: Effect.ALLOW,
343
351
  resources: [
344
- `arn:aws:logs:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:log-group:${
352
+ `arn:aws:logs:${Stack.of(scope).region}:${Stack.of(scope).account}:log-group:${
345
353
  logGroup.logGroupName
346
- }:log-stream:${cdk.Stack.of(scope).account}_CloudTrail_eu-west-1*`,
354
+ }:log-stream:${Stack.of(scope).account}_CloudTrail_eu-west-1*`,
347
355
  ],
348
356
  sid: 'AWSCloudTrailCreateLogStream2014110',
349
357
  })
@@ -354,9 +362,9 @@ export class IamManager {
354
362
  * @param resourceArns list of ARNs to allow access to
355
363
  */
356
364
  public statementForCreateAnyLogStream(resourceArns?: string[]) {
357
- return new iam.PolicyStatement({
365
+ return new PolicyStatement({
358
366
  actions: ['logs:CreateLogStream'],
359
- effect: iam.Effect.ALLOW,
367
+ effect: Effect.ALLOW,
360
368
  resources: resourceArns ?? ['*'],
361
369
  })
362
370
  }
@@ -366,14 +374,14 @@ export class IamManager {
366
374
  * @param scope scope in which this resource is defined
367
375
  * @param logGroup
368
376
  */
369
- public statementForPutLogEvent(scope: CommonConstruct, logGroup: logs.CfnLogGroup) {
370
- return new iam.PolicyStatement({
377
+ public statementForPutLogEvent(scope: CommonConstruct, logGroup: CfnLogGroup) {
378
+ return new PolicyStatement({
371
379
  actions: ['logs:PutLogEvents'],
372
- effect: iam.Effect.ALLOW,
380
+ effect: Effect.ALLOW,
373
381
  resources: [
374
- `arn:aws:logs:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:log-group:${
382
+ `arn:aws:logs:${Stack.of(scope).region}:${Stack.of(scope).account}:log-group:${
375
383
  logGroup.logGroupName
376
- }:log-stream:${cdk.Stack.of(scope).account}_CloudTrail_eu-west-1*`,
384
+ }:log-stream:${Stack.of(scope).account}_CloudTrail_eu-west-1*`,
377
385
  ],
378
386
  sid: 'AWSCloudTrailPutLogEvents20141101',
379
387
  })
@@ -384,9 +392,9 @@ export class IamManager {
384
392
  * @param resourceArns list of ARNs to allow access to
385
393
  */
386
394
  public statementForPutAnyLogEvent(resourceArns?: string[]) {
387
- return new iam.PolicyStatement({
395
+ return new PolicyStatement({
388
396
  actions: ['logs:PutLogEvents'],
389
- effect: iam.Effect.ALLOW,
397
+ effect: Effect.ALLOW,
390
398
  resources: resourceArns ?? ['*'],
391
399
  })
392
400
  }
@@ -396,7 +404,7 @@ export class IamManager {
396
404
  * @param resourceArns list of ARNs to allow access to
397
405
  */
398
406
  public statementForReadTableItems(resourceArns?: string[]) {
399
- return new iam.PolicyStatement({
407
+ return new PolicyStatement({
400
408
  actions: [
401
409
  'dynamodb:PartiQLSelect',
402
410
  'dynamodb:DescribeTable',
@@ -407,7 +415,7 @@ export class IamManager {
407
415
  'dynamodb:GetRecords',
408
416
  'dynamodb:BatchGetItem',
409
417
  ],
410
- effect: iam.Effect.ALLOW,
418
+ effect: Effect.ALLOW,
411
419
  resources: resourceArns ?? ['*'],
412
420
  })
413
421
  }
@@ -417,9 +425,9 @@ export class IamManager {
417
425
  * @param resourceArns list of ARNs to allow access to
418
426
  */
419
427
  public statementForWriteTableItems(resourceArns?: string[]) {
420
- return new iam.PolicyStatement({
428
+ return new PolicyStatement({
421
429
  actions: ['dynamodb:BatchWriteItem', 'dynamodb:DeleteItem', 'dynamodb:PutItem', 'dynamodb:UpdateItem'],
422
- effect: iam.Effect.ALLOW,
430
+ effect: Effect.ALLOW,
423
431
  resources: resourceArns ?? ['*'],
424
432
  })
425
433
  }
@@ -430,13 +438,13 @@ export class IamManager {
430
438
  * @param scope scope in which this resource is defined
431
439
  * @param logGroup
432
440
  */
433
- public createRoleForCloudTrail(id: string, scope: CommonConstruct, logGroup: logs.CfnLogGroup) {
434
- const policy = new iam.PolicyDocument({
441
+ public createRoleForCloudTrail(id: string, scope: CommonConstruct, logGroup: CfnLogGroup) {
442
+ const policy = new PolicyDocument({
435
443
  statements: [this.statementForCreateLogStream(scope, logGroup), this.statementForPutLogEvent(scope, logGroup)],
436
444
  })
437
- const role = new iam.CfnRole(scope, `${id}`, {
438
- assumeRolePolicyDocument: new iam.PolicyDocument({
439
- statements: [this.statementForAssumeRole(scope, [new iam.ServicePrincipal('cloudtrail.amazonaws.com')])],
445
+ const role = new CfnRole(scope, `${id}`, {
446
+ assumeRolePolicyDocument: new PolicyDocument({
447
+ statements: [this.statementForAssumeRole(scope, [new ServicePrincipal('cloudtrail.amazonaws.com')])],
440
448
  }),
441
449
  policies: [
442
450
  {
@@ -447,8 +455,8 @@ export class IamManager {
447
455
  roleName: `${id}-${scope.props.stage}`,
448
456
  })
449
457
 
450
- utils.createCfnOutput(`${id}Arn`, scope, role.attrArn)
451
- utils.createCfnOutput(`${id}Name`, scope, role.roleName)
458
+ createCfnOutput(`${id}Arn`, scope, role.attrArn)
459
+ createCfnOutput(`${id}Name`, scope, role.roleName)
452
460
 
453
461
  return role
454
462
  }
@@ -460,20 +468,20 @@ export class IamManager {
460
468
  * @param cluster
461
469
  * @param task
462
470
  */
463
- public createRoleForEcsEvent(id: string, scope: CommonConstruct, cluster: ecs.ICluster, task: ecs.ITaskDefinition) {
464
- const policy = new iam.PolicyDocument({
471
+ public createRoleForEcsEvent(id: string, scope: CommonConstruct, cluster: ICluster, task: ITaskDefinition) {
472
+ const policy = new PolicyDocument({
465
473
  statements: [this.statementForRunEcsTask(scope, cluster, task), this.statementForEcsPassRole()],
466
474
  })
467
475
 
468
- const role = new iam.Role(scope, `${id}`, {
469
- assumedBy: new iam.ServicePrincipal('events.amazonaws.com'),
476
+ const role = new Role(scope, `${id}`, {
477
+ assumedBy: new ServicePrincipal('events.amazonaws.com'),
470
478
  description: `Role for ${id} ECS Task execution from EventBridge`,
471
479
  inlinePolicies: { policy },
472
480
  roleName: `${id}-${scope.props.stage}`,
473
481
  })
474
482
 
475
- utils.createCfnOutput(`${id}Arn`, scope, role.roleArn)
476
- utils.createCfnOutput(`${id}Name`, scope, role.roleName)
483
+ createCfnOutput(`${id}Arn`, scope, role.roleArn)
484
+ createCfnOutput(`${id}Name`, scope, role.roleName)
477
485
 
478
486
  return role
479
487
  }
@@ -484,13 +492,13 @@ export class IamManager {
484
492
  * @param scope scope in which this resource is defined
485
493
  * @param policy
486
494
  */
487
- public createRoleForEcsExecution(id: string, scope: CommonConstruct, policy: iam.PolicyDocument) {
488
- const role = new iam.Role(scope, `${id}`, {
489
- assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'),
495
+ public createRoleForEcsExecution(id: string, scope: CommonConstruct, policy: PolicyDocument) {
496
+ const role = new Role(scope, `${id}`, {
497
+ assumedBy: new ServicePrincipal('ecs-tasks.amazonaws.com'),
490
498
  description: `Role for ${id} ECS Task execution`,
491
499
  inlinePolicies: { policy },
492
500
  managedPolicies: [
493
- iam.ManagedPolicy.fromManagedPolicyArn(
501
+ ManagedPolicy.fromManagedPolicyArn(
494
502
  scope,
495
503
  `${id}-AmazonECSTaskExecutionRolePolicy`,
496
504
  'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy'
@@ -499,8 +507,8 @@ export class IamManager {
499
507
  roleName: `${id}-${scope.props.stage}`,
500
508
  })
501
509
 
502
- utils.createCfnOutput(`${id}Arn`, scope, role.roleArn)
503
- utils.createCfnOutput(`${id}Name`, scope, role.roleName)
510
+ createCfnOutput(`${id}Arn`, scope, role.roleArn)
511
+ createCfnOutput(`${id}Name`, scope, role.roleName)
504
512
 
505
513
  return role
506
514
  }
@@ -510,20 +518,20 @@ export class IamManager {
510
518
  * @param id scoped id of the resource
511
519
  * @param scope scope in which this resource is defined
512
520
  * @param policy
513
- * @param servicePrinicpal
521
+ * @param servicePrincipal
514
522
  */
515
523
  public createRoleForLambda(
516
524
  id: string,
517
525
  scope: CommonConstruct,
518
- policy: iam.PolicyDocument,
519
- servicePrinicpal?: iam.ServicePrincipal
526
+ policy: PolicyDocument,
527
+ servicePrincipal?: ServicePrincipal
520
528
  ) {
521
- const role = new iam.Role(scope, `${id}`, {
522
- assumedBy: servicePrinicpal ?? new iam.ServicePrincipal('lambda.amazonaws.com'),
529
+ const role = new Role(scope, `${id}`, {
530
+ assumedBy: servicePrincipal ?? new ServicePrincipal('lambda.amazonaws.com'),
523
531
  description: `Role for ${id} Lambda function`,
524
532
  inlinePolicies: { policy },
525
533
  managedPolicies: [
526
- iam.ManagedPolicy.fromManagedPolicyArn(
534
+ ManagedPolicy.fromManagedPolicyArn(
527
535
  scope,
528
536
  `${id}-AWSLambdaBasicExecutionRole`,
529
537
  'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
@@ -532,8 +540,8 @@ export class IamManager {
532
540
  roleName: `${id}-${scope.props.stage}`,
533
541
  })
534
542
 
535
- utils.createCfnOutput(`${id}Arn`, scope, role.roleArn)
536
- utils.createCfnOutput(`${id}Name`, scope, role.roleName)
543
+ createCfnOutput(`${id}Arn`, scope, role.roleArn)
544
+ createCfnOutput(`${id}Name`, scope, role.roleName)
537
545
 
538
546
  return role
539
547
  }
@@ -543,23 +551,23 @@ export class IamManager {
543
551
  * @param id scoped id of the resource
544
552
  * @param scope scope in which this resource is defined
545
553
  * @param policy
546
- * @param servicePrinicpal
554
+ * @param servicePrincipal
547
555
  */
548
556
  public createRoleForAppConfigSecrets(
549
557
  id: string,
550
558
  scope: CommonConstruct,
551
- policy: iam.PolicyDocument,
552
- servicePrinicpal?: iam.ServicePrincipal
559
+ policy: PolicyDocument,
560
+ servicePrincipal?: ServicePrincipal
553
561
  ) {
554
- const role = new iam.Role(scope, `${id}`, {
555
- assumedBy: servicePrinicpal ?? new iam.ServicePrincipal('appconfig.amazonaws.com'),
562
+ const role = new Role(scope, `${id}`, {
563
+ assumedBy: servicePrincipal ?? new ServicePrincipal('appconfig.amazonaws.com'),
556
564
  description: `Role for ${id} AppConfig Secrets`,
557
565
  inlinePolicies: { policy },
558
566
  roleName: `${id}-${scope.props.stage}`,
559
567
  })
560
568
 
561
- utils.createCfnOutput(`${id}Arn`, scope, role.roleArn)
562
- utils.createCfnOutput(`${id}Name`, scope, role.roleName)
569
+ createCfnOutput(`${id}Arn`, scope, role.roleArn)
570
+ createCfnOutput(`${id}Name`, scope, role.roleName)
563
571
 
564
572
  return role
565
573
  }
@@ -569,20 +577,20 @@ export class IamManager {
569
577
  * @param id scoped id of the resource
570
578
  * @param scope scope in which this resource is defined
571
579
  * @param policy
572
- * @param servicePrinicpal
580
+ * @param servicePrincipal
573
581
  */
574
582
  public createRoleForStepFunction(
575
583
  id: string,
576
584
  scope: CommonConstruct,
577
- policy: iam.PolicyDocument,
578
- servicePrinicpal?: iam.ServicePrincipal
585
+ policy: PolicyDocument,
586
+ servicePrincipal?: ServicePrincipal
579
587
  ) {
580
- const role = new iam.Role(scope, `${id}`, {
581
- assumedBy: servicePrinicpal ?? new iam.ServicePrincipal('states.amazonaws.com'),
588
+ const role = new Role(scope, `${id}`, {
589
+ assumedBy: servicePrincipal ?? new ServicePrincipal('states.amazonaws.com'),
582
590
  description: `Role for ${id} Lambda function`,
583
591
  inlinePolicies: { policy },
584
592
  managedPolicies: [
585
- iam.ManagedPolicy.fromManagedPolicyArn(
593
+ ManagedPolicy.fromManagedPolicyArn(
586
594
  scope,
587
595
  `${id}-AWSLambdaBasicExecutionRole`,
588
596
  'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
@@ -591,8 +599,8 @@ export class IamManager {
591
599
  roleName: `${id}-${scope.props.stage}`,
592
600
  })
593
601
 
594
- utils.createCfnOutput(`${id}Arn`, scope, role.roleArn)
595
- utils.createCfnOutput(`${id}Name`, scope, role.roleName)
602
+ createCfnOutput(`${id}Arn`, scope, role.roleArn)
603
+ createCfnOutput(`${id}Name`, scope, role.roleName)
596
604
 
597
605
  return role
598
606
  }
@@ -605,8 +613,8 @@ export class IamManager {
605
613
  * @param stepFunctionArn the arn of the step function
606
614
  */
607
615
  public createRoleForSqsToSfnPipe(id: string, scope: CommonConstruct, queueArn: string, stepFunctionArn: string) {
608
- const role = new iam.Role(scope, `${id}`, {
609
- assumedBy: new iam.ServicePrincipal('pipes.amazonaws.com'),
616
+ const role = new Role(scope, `${id}`, {
617
+ assumedBy: new ServicePrincipal('pipes.amazonaws.com'),
610
618
  description: `Role for ${id} Pipe`,
611
619
  roleName: `${id}-${scope.props.stage}`,
612
620
  })
@@ -614,8 +622,8 @@ export class IamManager {
614
622
  role.addToPolicy(this.statementForPollQueue([queueArn]))
615
623
  role.addToPolicy(this.statementForStartExecution([stepFunctionArn]))
616
624
 
617
- utils.createCfnOutput(`${id}Arn`, scope, role.roleArn)
618
- utils.createCfnOutput(`${id}Name`, scope, role.roleName)
625
+ createCfnOutput(`${id}Arn`, scope, role.roleArn)
626
+ createCfnOutput(`${id}Name`, scope, role.roleName)
619
627
 
620
628
  return role
621
629
  }
@@ -631,21 +639,21 @@ export class IamManager {
631
639
  public createPolicyForSqsEvent(
632
640
  id: string,
633
641
  scope: CommonConstruct,
634
- sqsQueue: sqs.Queue,
635
- eventBridgeRule: events.IRule,
636
- servicePrincipals?: iam.ServicePrincipal[]
642
+ sqsQueue: Queue,
643
+ eventBridgeRule: IRule,
644
+ servicePrincipals?: ServicePrincipal[]
637
645
  ) {
638
- return new iam.PolicyDocument({
646
+ return new PolicyDocument({
639
647
  statements: [
640
- new iam.PolicyStatement({
648
+ new PolicyStatement({
641
649
  actions: ['sqs:*'],
642
650
  conditions: {
643
651
  ArnEquals: {
644
652
  'aws:SourceArn': eventBridgeRule,
645
653
  },
646
654
  },
647
- effect: iam.Effect.ALLOW,
648
- principals: servicePrincipals ?? [new iam.ServicePrincipal('events.amazonaws.com')],
655
+ effect: Effect.ALLOW,
656
+ principals: servicePrincipals ?? [new ServicePrincipal('events.amazonaws.com')],
649
657
  resources: [sqsQueue.queueArn],
650
658
  }),
651
659
  ],