@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.
- package/app/api-destined-function/package.json +1 -1
- package/dist/src/lib/common/construct.d.ts +32 -32
- package/dist/src/lib/common/construct.js +36 -59
- package/dist/src/lib/common/stack.d.ts +8 -7
- package/dist/src/lib/common/stack.js +17 -37
- package/dist/src/lib/common/types.d.ts +2 -2
- package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +22 -22
- package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +9 -9
- package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +3 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/main.js +37 -60
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +9 -9
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +3 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +40 -63
- package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +23 -23
- package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +2 -2
- package/dist/src/lib/construct/api-to-lambda-target/main.js +15 -38
- package/dist/src/lib/construct/application-configuration/main.d.ts +7 -7
- package/dist/src/lib/construct/application-configuration/main.js +17 -41
- package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +17 -17
- package/dist/src/lib/construct/graphql-api-lambda/main.js +6 -29
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +5 -5
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +7 -7
- package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +16 -16
- package/dist/src/lib/construct/lambda-with-iam-access/main.js +8 -31
- package/dist/src/lib/construct/lambda-with-iam-access/types.d.ts +4 -4
- package/dist/src/lib/construct/rest-api-lambda/main.d.ts +16 -16
- package/dist/src/lib/construct/rest-api-lambda/main.js +5 -28
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +5 -5
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +9 -32
- package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +38 -39
- package/dist/src/lib/construct/site-with-ecs-backend/main.js +33 -54
- package/dist/src/lib/construct/static-asset-deployment/main.d.ts +4 -4
- package/dist/src/lib/construct/static-asset-deployment/main.js +3 -26
- package/dist/src/lib/construct/static-site/main.d.ts +15 -15
- package/dist/src/lib/construct/static-site/main.js +4 -27
- package/dist/src/lib/services/aws/api-gateway/main.d.ts +10 -10
- package/dist/src/lib/services/aws/api-gateway/main.js +21 -44
- package/dist/src/lib/services/aws/api-gateway/types.d.ts +2 -2
- package/dist/src/lib/services/aws/appconfig/main.d.ts +7 -7
- package/dist/src/lib/services/aws/appconfig/main.js +14 -37
- package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -5
- package/dist/src/lib/services/aws/certificate-manager/main.js +10 -33
- package/dist/src/lib/services/aws/certificate-manager/types.d.ts +2 -2
- package/dist/src/lib/services/aws/cloudfront/main.d.ts +18 -18
- package/dist/src/lib/services/aws/cloudfront/main.js +46 -45
- package/dist/src/lib/services/aws/cloudfront/types.d.ts +2 -3
- package/dist/src/lib/services/aws/cloudtrail/main.d.ts +5 -5
- package/dist/src/lib/services/aws/cloudtrail/main.js +5 -28
- package/dist/src/lib/services/aws/codebuild/main.d.ts +3 -3
- package/dist/src/lib/services/aws/codebuild/main.js +7 -30
- package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -3
- package/dist/src/lib/services/aws/dynamodb/main.js +8 -31
- package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +2 -2
- package/dist/src/lib/services/aws/elastic-container-registry/main.js +4 -27
- package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +10 -10
- package/dist/src/lib/services/aws/elastic-container-service/main.js +27 -50
- package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +4 -4
- package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +3 -3
- package/dist/src/lib/services/aws/elastic-file-system/main.js +12 -35
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +4 -4
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -31
- package/dist/src/lib/services/aws/elasticache/main.d.ts +4 -4
- package/dist/src/lib/services/aws/elasticache/main.js +10 -33
- package/dist/src/lib/services/aws/eventbridge/main.d.ts +13 -13
- package/dist/src/lib/services/aws/eventbridge/main.js +26 -49
- package/dist/src/lib/services/aws/eventbridge/target.d.ts +10 -10
- package/dist/src/lib/services/aws/eventbridge/target.js +6 -29
- package/dist/src/lib/services/aws/evidently/main.d.ts +7 -7
- package/dist/src/lib/services/aws/evidently/main.js +18 -41
- package/dist/src/lib/services/aws/identity-access-management/main.d.ts +48 -49
- package/dist/src/lib/services/aws/identity-access-management/main.js +110 -133
- package/dist/src/lib/services/aws/key-management-service/main.d.ts +2 -2
- package/dist/src/lib/services/aws/key-management-service/main.js +5 -28
- package/dist/src/lib/services/aws/lambda/main.d.ts +11 -13
- package/dist/src/lib/services/aws/lambda/main.js +31 -58
- package/dist/src/lib/services/aws/route53/main.d.ts +9 -9
- package/dist/src/lib/services/aws/route53/main.js +21 -44
- package/dist/src/lib/services/aws/secrets-manager/main.d.ts +5 -6
- package/dist/src/lib/services/aws/secrets-manager/main.js +10 -33
- package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +4 -4
- package/dist/src/lib/services/aws/simple-notification-service/main.js +11 -34
- package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +6 -7
- package/dist/src/lib/services/aws/simple-queue-service/main.js +15 -38
- package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +10 -11
- package/dist/src/lib/services/aws/simple-storage-service/main.js +31 -54
- package/dist/src/lib/services/aws/step-function/main.d.ts +31 -32
- package/dist/src/lib/services/aws/step-function/main.js +33 -57
- package/dist/src/lib/services/aws/systems-manager/main.d.ts +4 -4
- package/dist/src/lib/services/aws/systems-manager/main.js +10 -33
- package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +5 -6
- package/dist/src/lib/services/aws/virtual-private-cloud/main.js +14 -37
- package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +3 -3
- package/dist/src/lib/services/aws/web-application-firewall/main.js +8 -31
- package/dist/src/lib/utils/aws/index.d.ts +6 -3
- package/dist/src/lib/utils/aws/index.js +9 -26
- package/package.json +15 -15
- package/src/lib/common/construct.ts +97 -67
- package/src/lib/common/stack.ts +12 -12
- package/src/lib/common/types.ts +2 -2
- package/src/lib/construct/api-to-eventbridge-target/api.ts +31 -22
- package/src/lib/construct/api-to-eventbridge-target/event.ts +9 -9
- package/src/lib/construct/api-to-eventbridge-target/main.ts +56 -41
- package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +9 -9
- package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +62 -47
- package/src/lib/construct/api-to-lambda-target/api.ts +33 -23
- package/src/lib/construct/api-to-lambda-target/main.ts +24 -18
- package/src/lib/construct/application-configuration/main.ts +31 -24
- package/src/lib/construct/graphql-api-lambda/main.ts +22 -22
- package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +13 -13
- package/src/lib/construct/lambda-with-iam-access/main.ts +25 -25
- package/src/lib/construct/lambda-with-iam-access/types.ts +4 -4
- package/src/lib/construct/rest-api-lambda/main.ts +21 -21
- package/src/lib/construct/rest-api-lambda-with-cache/main.ts +14 -14
- package/src/lib/construct/site-with-ecs-backend/main.ts +79 -60
- package/src/lib/construct/static-asset-deployment/main.ts +6 -6
- package/src/lib/construct/static-site/main.ts +23 -17
- package/src/lib/services/aws/api-gateway/main.ts +42 -36
- package/src/lib/services/aws/api-gateway/types.ts +2 -2
- package/src/lib/services/aws/appconfig/main.ts +19 -19
- package/src/lib/services/aws/certificate-manager/main.ts +14 -14
- package/src/lib/services/aws/certificate-manager/types.ts +2 -2
- package/src/lib/services/aws/cloudfront/main.ts +88 -74
- package/src/lib/services/aws/cloudfront/types.ts +6 -3
- package/src/lib/services/aws/cloudtrail/main.ts +11 -11
- package/src/lib/services/aws/codebuild/main.ts +7 -7
- package/src/lib/services/aws/dynamodb/main.ts +8 -8
- package/src/lib/services/aws/elastic-container-registry/main.ts +4 -4
- package/src/lib/services/aws/elastic-container-service/main.ts +48 -37
- package/src/lib/services/aws/elastic-container-service/types.ts +4 -4
- package/src/lib/services/aws/elastic-file-system/main.ts +16 -16
- package/src/lib/services/aws/elastic-kubernetes-service/main.ts +11 -11
- package/src/lib/services/aws/elasticache/main.ts +10 -10
- package/src/lib/services/aws/eventbridge/main.ts +37 -37
- package/src/lib/services/aws/eventbridge/target.ts +14 -14
- package/src/lib/services/aws/evidently/main.ts +18 -18
- package/src/lib/services/aws/identity-access-management/main.ts +142 -134
- package/src/lib/services/aws/key-management-service/main.ts +5 -5
- package/src/lib/services/aws/lambda/main.ts +65 -59
- package/src/lib/services/aws/route53/main.ts +31 -31
- package/src/lib/services/aws/secrets-manager/main.ts +11 -15
- package/src/lib/services/aws/simple-notification-service/main.ts +13 -13
- package/src/lib/services/aws/simple-queue-service/main.ts +18 -18
- package/src/lib/services/aws/simple-storage-service/main.ts +40 -40
- package/src/lib/services/aws/step-function/main.ts +77 -65
- package/src/lib/services/aws/systems-manager/main.ts +17 -12
- package/src/lib/services/aws/virtual-private-cloud/main.ts +16 -16
- package/src/lib/services/aws/web-application-firewall/main.ts +8 -8
- package/src/lib/utils/aws/index.ts +8 -5
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
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:
|
|
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
|
|
42
|
+
return new PolicyStatement({
|
|
35
43
|
actions: ['secretsmanager:GetSecretValue'],
|
|
36
|
-
effect:
|
|
44
|
+
effect: Effect.ALLOW,
|
|
37
45
|
resources: resourceArns ?? [
|
|
38
|
-
`arn:aws:secretsmanager:${
|
|
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
|
|
56
|
+
return new PolicyStatement({
|
|
49
57
|
actions: ['events:PutEvents'],
|
|
50
|
-
effect:
|
|
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
|
|
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
|
|
68
|
+
return new PolicyStatement({
|
|
61
69
|
actions: ['states:StartExecution'],
|
|
62
|
-
effect:
|
|
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
|
|
80
|
+
return new PolicyStatement({
|
|
73
81
|
actions: ['sqs:ReceiveMessage', 'sqs:DeleteMessage', 'sqs:GetQueueAttributes'],
|
|
74
|
-
effect:
|
|
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
|
|
92
|
+
return new PolicyStatement({
|
|
85
93
|
actions: ['lambda:InvokeFunction'],
|
|
86
|
-
effect:
|
|
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
|
|
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:
|
|
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
|
|
129
|
+
return new PolicyStatement({
|
|
122
130
|
actions: ['appconfig:GetLatestConfiguration', 'appconfig:StartConfigurationSession'],
|
|
123
|
-
effect:
|
|
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
|
|
141
|
+
return new PolicyStatement({
|
|
134
142
|
actions: ['xray:PutTraceSegments', 'xray:PutTelemetryRecords'],
|
|
135
|
-
effect:
|
|
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
|
|
153
|
+
return new PolicyStatement({
|
|
146
154
|
actions: ['kms:Decrypt'],
|
|
147
|
-
effect:
|
|
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:
|
|
158
|
-
return new
|
|
165
|
+
public statementForListBucket(scope: CommonConstruct, bucket: IBucket) {
|
|
166
|
+
return new PolicyStatement({
|
|
159
167
|
actions: ['s3:ListBucket'],
|
|
160
|
-
effect:
|
|
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
|
|
178
|
+
return new PolicyStatement({
|
|
171
179
|
actions: ['s3:ListAllMyBuckets'],
|
|
172
|
-
effect:
|
|
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:
|
|
184
|
-
return new
|
|
191
|
+
public statementForGetAnyS3Objects(scope: CommonConstruct, bucket: IBucket, resourceArns?: string[]) {
|
|
192
|
+
return new PolicyStatement({
|
|
185
193
|
actions: ['s3:GetObject', 's3:GetObjectAcl'],
|
|
186
|
-
effect:
|
|
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:
|
|
198
|
-
return new
|
|
205
|
+
public statementForDeleteAnyS3Objects(scope: CommonConstruct, bucket: IBucket, resourceArns?: string[]) {
|
|
206
|
+
return new PolicyStatement({
|
|
199
207
|
actions: ['s3:DeleteObject'],
|
|
200
|
-
effect:
|
|
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:
|
|
212
|
-
return new
|
|
219
|
+
public statementForPutAnyS3Objects(scope: CommonConstruct, bucket: IBucket, resourceArns?: string[]) {
|
|
220
|
+
return new PolicyStatement({
|
|
213
221
|
actions: ['s3:PutObject', 's3:PutObjectAcl'],
|
|
214
|
-
effect:
|
|
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
|
|
232
|
+
return new PolicyStatement({
|
|
225
233
|
actions: ['iam:PassRole'],
|
|
226
|
-
effect:
|
|
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
|
|
244
|
+
return new PolicyStatement({
|
|
237
245
|
actions: ['cloudfront:GetInvalidation', 'cloudfront:CreateInvalidation'],
|
|
238
|
-
effect:
|
|
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
|
|
256
|
+
return new PolicyStatement({
|
|
249
257
|
actions: ['elasticfilesystem:*'],
|
|
250
|
-
effect:
|
|
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
|
|
268
|
+
return new PolicyDocument({
|
|
261
269
|
statements: [
|
|
262
270
|
this.statementForCreateAnyLogStream(),
|
|
263
271
|
this.statementForPutAnyLogEvent(),
|
|
264
272
|
this.statementForCloudfrontInvalidation(),
|
|
265
|
-
new
|
|
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:
|
|
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
|
|
286
|
-
assumedBy: new
|
|
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:
|
|
299
|
-
return new
|
|
306
|
+
public statementForAssumeRole(scope: CommonConstruct, servicePrincipals: ServicePrincipal[]) {
|
|
307
|
+
return new PolicyStatement({
|
|
300
308
|
actions: ['sts:AssumeRole'],
|
|
301
|
-
effect:
|
|
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
|
|
319
|
+
return new PolicyStatement({
|
|
312
320
|
actions: ['iam:PassRole'],
|
|
313
321
|
conditions: { StringLike: { 'iam:PassedToService': 'ecs-tasks.amazonaws.com' } },
|
|
314
|
-
effect:
|
|
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:
|
|
326
|
-
return new
|
|
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:
|
|
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:
|
|
340
|
-
return new
|
|
347
|
+
public statementForCreateLogStream(scope: CommonConstruct, logGroup: CfnLogGroup) {
|
|
348
|
+
return new PolicyStatement({
|
|
341
349
|
actions: ['logs:CreateLogStream'],
|
|
342
|
-
effect:
|
|
350
|
+
effect: Effect.ALLOW,
|
|
343
351
|
resources: [
|
|
344
|
-
`arn:aws:logs:${
|
|
352
|
+
`arn:aws:logs:${Stack.of(scope).region}:${Stack.of(scope).account}:log-group:${
|
|
345
353
|
logGroup.logGroupName
|
|
346
|
-
}:log-stream:${
|
|
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
|
|
365
|
+
return new PolicyStatement({
|
|
358
366
|
actions: ['logs:CreateLogStream'],
|
|
359
|
-
effect:
|
|
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:
|
|
370
|
-
return new
|
|
377
|
+
public statementForPutLogEvent(scope: CommonConstruct, logGroup: CfnLogGroup) {
|
|
378
|
+
return new PolicyStatement({
|
|
371
379
|
actions: ['logs:PutLogEvents'],
|
|
372
|
-
effect:
|
|
380
|
+
effect: Effect.ALLOW,
|
|
373
381
|
resources: [
|
|
374
|
-
`arn:aws:logs:${
|
|
382
|
+
`arn:aws:logs:${Stack.of(scope).region}:${Stack.of(scope).account}:log-group:${
|
|
375
383
|
logGroup.logGroupName
|
|
376
|
-
}:log-stream:${
|
|
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
|
|
395
|
+
return new PolicyStatement({
|
|
388
396
|
actions: ['logs:PutLogEvents'],
|
|
389
|
-
effect:
|
|
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
|
|
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:
|
|
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
|
|
428
|
+
return new PolicyStatement({
|
|
421
429
|
actions: ['dynamodb:BatchWriteItem', 'dynamodb:DeleteItem', 'dynamodb:PutItem', 'dynamodb:UpdateItem'],
|
|
422
|
-
effect:
|
|
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:
|
|
434
|
-
const policy = new
|
|
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
|
|
438
|
-
assumeRolePolicyDocument: new
|
|
439
|
-
statements: [this.statementForAssumeRole(scope, [new
|
|
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
|
-
|
|
451
|
-
|
|
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:
|
|
464
|
-
const policy = new
|
|
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
|
|
469
|
-
assumedBy: new
|
|
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
|
-
|
|
476
|
-
|
|
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:
|
|
488
|
-
const role = new
|
|
489
|
-
assumedBy: new
|
|
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
|
-
|
|
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
|
-
|
|
503
|
-
|
|
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
|
|
521
|
+
* @param servicePrincipal
|
|
514
522
|
*/
|
|
515
523
|
public createRoleForLambda(
|
|
516
524
|
id: string,
|
|
517
525
|
scope: CommonConstruct,
|
|
518
|
-
policy:
|
|
519
|
-
|
|
526
|
+
policy: PolicyDocument,
|
|
527
|
+
servicePrincipal?: ServicePrincipal
|
|
520
528
|
) {
|
|
521
|
-
const role = new
|
|
522
|
-
assumedBy:
|
|
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
|
-
|
|
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
|
-
|
|
536
|
-
|
|
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
|
|
554
|
+
* @param servicePrincipal
|
|
547
555
|
*/
|
|
548
556
|
public createRoleForAppConfigSecrets(
|
|
549
557
|
id: string,
|
|
550
558
|
scope: CommonConstruct,
|
|
551
|
-
policy:
|
|
552
|
-
|
|
559
|
+
policy: PolicyDocument,
|
|
560
|
+
servicePrincipal?: ServicePrincipal
|
|
553
561
|
) {
|
|
554
|
-
const role = new
|
|
555
|
-
assumedBy:
|
|
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
|
-
|
|
562
|
-
|
|
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
|
|
580
|
+
* @param servicePrincipal
|
|
573
581
|
*/
|
|
574
582
|
public createRoleForStepFunction(
|
|
575
583
|
id: string,
|
|
576
584
|
scope: CommonConstruct,
|
|
577
|
-
policy:
|
|
578
|
-
|
|
585
|
+
policy: PolicyDocument,
|
|
586
|
+
servicePrincipal?: ServicePrincipal
|
|
579
587
|
) {
|
|
580
|
-
const role = new
|
|
581
|
-
assumedBy:
|
|
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
|
-
|
|
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
|
-
|
|
595
|
-
|
|
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
|
|
609
|
-
assumedBy: new
|
|
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
|
-
|
|
618
|
-
|
|
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:
|
|
635
|
-
eventBridgeRule:
|
|
636
|
-
servicePrincipals?:
|
|
642
|
+
sqsQueue: Queue,
|
|
643
|
+
eventBridgeRule: IRule,
|
|
644
|
+
servicePrincipals?: ServicePrincipal[]
|
|
637
645
|
) {
|
|
638
|
-
return new
|
|
646
|
+
return new PolicyDocument({
|
|
639
647
|
statements: [
|
|
640
|
-
new
|
|
648
|
+
new PolicyStatement({
|
|
641
649
|
actions: ['sqs:*'],
|
|
642
650
|
conditions: {
|
|
643
651
|
ArnEquals: {
|
|
644
652
|
'aws:SourceArn': eventBridgeRule,
|
|
645
653
|
},
|
|
646
654
|
},
|
|
647
|
-
effect:
|
|
648
|
-
principals: servicePrincipals ?? [new
|
|
655
|
+
effect: Effect.ALLOW,
|
|
656
|
+
principals: servicePrincipals ?? [new ServicePrincipal('events.amazonaws.com')],
|
|
649
657
|
resources: [sqsQueue.queueArn],
|
|
650
658
|
}),
|
|
651
659
|
],
|