@gradientedge/cdk-utils 8.90.0 → 8.92.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/.eslintrc.json +40 -0
- package/app/api-destined-function/src/lib/lambda.ts +6 -6
- package/dist/app/api-destined-function/src/lib/lambda.d.ts +6 -6
- package/dist/app/api-destined-function/src/lib/lambda.js +6 -6
- package/dist/lib/lambda.d.ts +6 -6
- package/dist/lib/lambda.js +6 -6
- package/dist/lib/lambda.js.map +1 -1
- package/dist/src/lib/common/construct.d.ts +4 -7
- package/dist/src/lib/common/construct.js +4 -7
- package/dist/src/lib/common/stack.d.ts +9 -13
- package/dist/src/lib/common/stack.js +9 -13
- package/dist/src/lib/common/types.d.ts +0 -2
- package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/api.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/event.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +0 -27
- package/dist/src/lib/construct/api-to-eventbridge-target/main.js +41 -68
- package/dist/src/lib/construct/api-to-eventbridge-target/types.d.ts +13 -25
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +0 -37
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +44 -81
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/types.d.ts +1 -5
- package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +0 -3
- package/dist/src/lib/construct/api-to-lambda-target/api.js +0 -3
- package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +0 -14
- package/dist/src/lib/construct/api-to-lambda-target/main.js +7 -21
- package/dist/src/lib/construct/api-to-lambda-target/types.d.ts +7 -13
- package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +0 -18
- package/dist/src/lib/construct/graphql-api-lambda/main.js +1 -19
- package/dist/src/lib/construct/graphql-api-lambda/types.d.ts +4 -8
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +0 -11
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +1 -12
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/types.d.ts +1 -3
- package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +0 -12
- package/dist/src/lib/construct/lambda-with-iam-access/main.js +2 -14
- package/dist/src/lib/construct/rest-api-lambda/main.d.ts +0 -18
- package/dist/src/lib/construct/rest-api-lambda/main.js +1 -19
- package/dist/src/lib/construct/rest-api-lambda/types.d.ts +7 -12
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +0 -11
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +3 -14
- package/dist/src/lib/construct/rest-api-lambda-with-cache/types.d.ts +1 -3
- package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +0 -25
- package/dist/src/lib/construct/site-with-ecs-backend/main.js +32 -52
- package/dist/src/lib/construct/site-with-ecs-backend/types.d.ts +10 -11
- package/dist/src/lib/construct/static-asset-deployment/main.d.ts +0 -8
- package/dist/src/lib/construct/static-asset-deployment/main.js +0 -8
- package/dist/src/lib/construct/static-asset-deployment/types.d.ts +1 -1
- package/dist/src/lib/construct/static-site/main.d.ts +0 -17
- package/dist/src/lib/construct/static-site/main.js +1 -18
- package/dist/src/lib/construct/static-site/types.d.ts +9 -11
- package/dist/src/lib/services/aws/api-gateway/main.d.ts +21 -25
- package/dist/src/lib/services/aws/api-gateway/main.js +42 -46
- package/dist/src/lib/services/aws/api-gateway/types.d.ts +0 -2
- package/dist/src/lib/services/aws/appconfig/constants.d.ts +0 -6
- package/dist/src/lib/services/aws/appconfig/constants.js +26 -32
- package/dist/src/lib/services/aws/appconfig/main.d.ts +16 -19
- package/dist/src/lib/services/aws/appconfig/main.js +19 -22
- package/dist/src/lib/services/aws/appconfig/types.d.ts +1 -3
- package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -10
- package/dist/src/lib/services/aws/certificate-manager/main.js +5 -10
- package/dist/src/lib/services/aws/certificate-manager/types.d.ts +3 -5
- package/dist/src/lib/services/aws/cloudfront/main.d.ts +41 -47
- package/dist/src/lib/services/aws/cloudfront/main.js +56 -62
- package/dist/src/lib/services/aws/cloudfront/types.d.ts +1 -7
- package/dist/src/lib/services/aws/cloudtrail/main.d.ts +8 -12
- package/dist/src/lib/services/aws/cloudtrail/main.js +8 -12
- package/dist/src/lib/services/aws/cloudtrail/types.d.ts +0 -2
- package/dist/src/lib/services/aws/cloudwatch/logs.d.ts +11 -15
- package/dist/src/lib/services/aws/cloudwatch/logs.js +15 -19
- package/dist/src/lib/services/aws/cloudwatch/main.d.ts +80 -84
- package/dist/src/lib/services/aws/cloudwatch/main.js +116 -122
- package/dist/src/lib/services/aws/cloudwatch/types.d.ts +20 -42
- package/dist/src/lib/services/aws/codebuild/main.d.ts +0 -4
- package/dist/src/lib/services/aws/codebuild/main.js +3 -7
- package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -7
- package/dist/src/lib/services/aws/dynamodb/main.js +13 -17
- package/dist/src/lib/services/aws/dynamodb/types.d.ts +0 -2
- package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +3 -7
- package/dist/src/lib/services/aws/elastic-container-registry/main.js +3 -7
- package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +19 -23
- package/dist/src/lib/services/aws/elastic-container-service/main.js +35 -39
- package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +1 -9
- package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +9 -13
- package/dist/src/lib/services/aws/elastic-file-system/main.js +14 -18
- package/dist/src/lib/services/aws/elastic-file-system/types.d.ts +1 -5
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +5 -9
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -12
- package/dist/src/lib/services/aws/elastic-kubernetes-service/types.d.ts +1 -3
- package/dist/src/lib/services/aws/elasticache/main.d.ts +14 -18
- package/dist/src/lib/services/aws/elasticache/main.js +35 -39
- package/dist/src/lib/services/aws/elasticache/types.d.ts +0 -4
- package/dist/src/lib/services/aws/eventbridge/main.d.ts +25 -29
- package/dist/src/lib/services/aws/eventbridge/main.js +34 -38
- package/dist/src/lib/services/aws/eventbridge/target.d.ts +6 -9
- package/dist/src/lib/services/aws/eventbridge/target.js +8 -10
- package/dist/src/lib/services/aws/eventbridge/types.d.ts +2 -10
- package/dist/src/lib/services/aws/evidently/main.d.ts +15 -19
- package/dist/src/lib/services/aws/evidently/main.js +19 -23
- package/dist/src/lib/services/aws/evidently/types.d.ts +0 -10
- package/dist/src/lib/services/aws/identity-access-management/main.d.ts +66 -70
- package/dist/src/lib/services/aws/identity-access-management/main.js +97 -101
- package/dist/src/lib/services/aws/key-management-service/main.d.ts +3 -7
- package/dist/src/lib/services/aws/key-management-service/main.js +6 -10
- package/dist/src/lib/services/aws/key-management-service/types.d.ts +0 -2
- package/dist/src/lib/services/aws/lambda/main.d.ts +42 -47
- package/dist/src/lib/services/aws/lambda/main.js +64 -69
- package/dist/src/lib/services/aws/lambda/types.d.ts +6 -16
- package/dist/src/lib/services/aws/route53/main.d.ts +17 -21
- package/dist/src/lib/services/aws/route53/main.js +19 -23
- package/dist/src/lib/services/aws/route53/types.d.ts +0 -2
- package/dist/src/lib/services/aws/secrets-manager/main.d.ts +6 -19
- package/dist/src/lib/services/aws/secrets-manager/main.js +6 -25
- package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +8 -12
- package/dist/src/lib/services/aws/simple-notification-service/main.js +10 -14
- package/dist/src/lib/services/aws/simple-notification-service/types.d.ts +0 -2
- package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +11 -15
- package/dist/src/lib/services/aws/simple-queue-service/main.js +19 -23
- package/dist/src/lib/services/aws/simple-queue-service/types.d.ts +4 -6
- package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +24 -32
- package/dist/src/lib/services/aws/simple-storage-service/main.js +32 -40
- package/dist/src/lib/services/aws/simple-storage-service/types.d.ts +2 -8
- package/dist/src/lib/services/aws/step-function/main.d.ts +55 -59
- package/dist/src/lib/services/aws/step-function/main.js +91 -95
- package/dist/src/lib/services/aws/step-function/types.d.ts +0 -32
- package/dist/src/lib/services/aws/systems-manager/main.d.ts +10 -16
- package/dist/src/lib/services/aws/systems-manager/main.js +13 -19
- package/dist/src/lib/services/aws/systems-manager/types.d.ts +0 -2
- package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +9 -12
- package/dist/src/lib/services/aws/virtual-private-cloud/main.js +10 -16
- package/dist/src/lib/services/aws/web-application-firewall/index.d.ts +1 -0
- package/dist/src/lib/services/aws/web-application-firewall/index.js +1 -0
- package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +6 -10
- package/dist/src/lib/services/aws/web-application-firewall/main.js +12 -16
- package/dist/src/lib/services/aws/web-application-firewall/types.d.ts +0 -4
- package/dist/src/lib/types/aws/index.d.ts +0 -2
- package/dist/src/lib/utils/aws/index.d.ts +6 -9
- package/dist/src/lib/utils/aws/index.js +7 -10
- package/dist/src/lib/utils/index.d.ts +6 -13
- package/dist/src/lib/utils/index.js +4 -12
- package/package.json +5 -5
- package/src/lib/common/construct.ts +4 -7
- package/src/lib/common/stack.ts +9 -13
- package/src/lib/common/types.ts +0 -2
- package/src/lib/construct/api-to-eventbridge-target/api.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target/event.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target/main.ts +41 -68
- package/src/lib/construct/api-to-eventbridge-target/types.ts +13 -25
- package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +44 -81
- package/src/lib/construct/api-to-eventbridge-target-with-sns/types.ts +1 -5
- package/src/lib/construct/api-to-lambda-target/api.ts +0 -3
- package/src/lib/construct/api-to-lambda-target/main.ts +7 -21
- package/src/lib/construct/api-to-lambda-target/types.ts +7 -13
- package/src/lib/construct/graphql-api-lambda/main.ts +1 -19
- package/src/lib/construct/graphql-api-lambda/types.ts +4 -8
- package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +1 -12
- package/src/lib/construct/graphql-api-lambda-with-cache/types.ts +1 -3
- package/src/lib/construct/lambda-with-iam-access/main.ts +2 -14
- package/src/lib/construct/rest-api-lambda/main.ts +1 -19
- package/src/lib/construct/rest-api-lambda/types.ts +7 -12
- package/src/lib/construct/rest-api-lambda-with-cache/main.ts +3 -14
- package/src/lib/construct/rest-api-lambda-with-cache/types.ts +1 -3
- package/src/lib/construct/site-with-ecs-backend/main.ts +31 -52
- package/src/lib/construct/site-with-ecs-backend/types.ts +10 -11
- package/src/lib/construct/static-asset-deployment/main.ts +0 -8
- package/src/lib/construct/static-asset-deployment/types.ts +1 -1
- package/src/lib/construct/static-site/main.ts +1 -18
- package/src/lib/construct/static-site/types.ts +9 -11
- package/src/lib/services/aws/api-gateway/main.ts +43 -47
- package/src/lib/services/aws/api-gateway/types.ts +0 -2
- package/src/lib/services/aws/appconfig/constants.ts +26 -32
- package/src/lib/services/aws/appconfig/main.ts +19 -22
- package/src/lib/services/aws/appconfig/types.ts +1 -3
- package/src/lib/services/aws/certificate-manager/main.ts +5 -10
- package/src/lib/services/aws/certificate-manager/types.ts +3 -5
- package/src/lib/services/aws/cloudfront/main.ts +56 -62
- package/src/lib/services/aws/cloudfront/types.ts +1 -7
- package/src/lib/services/aws/cloudtrail/main.ts +8 -12
- package/src/lib/services/aws/cloudtrail/types.ts +0 -2
- package/src/lib/services/aws/cloudwatch/logs.ts +15 -19
- package/src/lib/services/aws/cloudwatch/main.ts +116 -122
- package/src/lib/services/aws/cloudwatch/types.ts +20 -42
- package/src/lib/services/aws/codebuild/main.ts +3 -7
- package/src/lib/services/aws/dynamodb/main.ts +13 -17
- package/src/lib/services/aws/dynamodb/types.ts +0 -2
- package/src/lib/services/aws/elastic-container-registry/main.ts +3 -7
- package/src/lib/services/aws/elastic-container-service/main.ts +35 -39
- package/src/lib/services/aws/elastic-container-service/types.ts +1 -9
- package/src/lib/services/aws/elastic-file-system/main.ts +14 -18
- package/src/lib/services/aws/elastic-file-system/types.ts +1 -5
- package/src/lib/services/aws/elastic-kubernetes-service/main.ts +8 -12
- package/src/lib/services/aws/elastic-kubernetes-service/types.ts +1 -3
- package/src/lib/services/aws/elasticache/main.ts +35 -39
- package/src/lib/services/aws/elasticache/types.ts +0 -4
- package/src/lib/services/aws/eventbridge/main.ts +34 -38
- package/src/lib/services/aws/eventbridge/target.ts +8 -11
- package/src/lib/services/aws/eventbridge/types.ts +2 -10
- package/src/lib/services/aws/evidently/main.ts +19 -23
- package/src/lib/services/aws/evidently/types.ts +0 -10
- package/src/lib/services/aws/identity-access-management/main.ts +97 -101
- package/src/lib/services/aws/key-management-service/main.ts +6 -10
- package/src/lib/services/aws/key-management-service/types.ts +0 -2
- package/src/lib/services/aws/lambda/main.ts +64 -69
- package/src/lib/services/aws/lambda/types.ts +6 -16
- package/src/lib/services/aws/route53/main.ts +19 -23
- package/src/lib/services/aws/route53/types.ts +0 -2
- package/src/lib/services/aws/secrets-manager/main.ts +6 -28
- package/src/lib/services/aws/simple-notification-service/main.ts +10 -14
- package/src/lib/services/aws/simple-notification-service/types.ts +0 -2
- package/src/lib/services/aws/simple-queue-service/main.ts +19 -23
- package/src/lib/services/aws/simple-queue-service/types.ts +4 -6
- package/src/lib/services/aws/simple-storage-service/main.ts +32 -40
- package/src/lib/services/aws/simple-storage-service/types.ts +2 -8
- package/src/lib/services/aws/step-function/main.ts +91 -95
- package/src/lib/services/aws/step-function/types.ts +0 -32
- package/src/lib/services/aws/systems-manager/main.ts +13 -19
- package/src/lib/services/aws/systems-manager/types.ts +0 -2
- package/src/lib/services/aws/virtual-private-cloud/main.ts +10 -16
- package/src/lib/services/aws/web-application-firewall/index.ts +1 -0
- package/src/lib/services/aws/web-application-firewall/main.ts +12 -16
- package/src/lib/services/aws/web-application-firewall/types.ts +0 -4
- package/src/lib/types/aws/index.ts +0 -2
- package/src/lib/utils/aws/index.ts +7 -10
- package/src/lib/utils/index.ts +4 -12
|
@@ -9,9 +9,6 @@ import * as utils from '../../../utils'
|
|
|
9
9
|
import { CommonConstruct } from '../../../common'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @stability stable
|
|
13
|
-
* @category cdk-utils.iam-manager
|
|
14
|
-
* @subcategory Construct
|
|
15
12
|
* @classdesc Provides operations on AWS IAM.
|
|
16
13
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
17
14
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -25,19 +22,18 @@ import { CommonConstruct } from '../../../common'
|
|
|
25
22
|
* this.iamManager.createRoleForEcsEvent('MyEcsRole', this, cluster, task)
|
|
26
23
|
* }
|
|
27
24
|
* }
|
|
28
|
-
*
|
|
29
25
|
* @see [CDK IAM Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam-readme.html}
|
|
30
26
|
*/
|
|
31
27
|
export class IamManager {
|
|
32
28
|
/**
|
|
33
29
|
* @summary Method to create iam statement to read secrets
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
30
|
+
* @param scope scope in which this resource is defined
|
|
31
|
+
* @param resourceArns list of ARNs to allow access to
|
|
36
32
|
*/
|
|
37
33
|
public statementForReadSecrets(scope: CommonConstruct, resourceArns?: string[]) {
|
|
38
34
|
return new iam.PolicyStatement({
|
|
39
|
-
effect: iam.Effect.ALLOW,
|
|
40
35
|
actions: ['secretsmanager:GetSecretValue'],
|
|
36
|
+
effect: iam.Effect.ALLOW,
|
|
41
37
|
resources: resourceArns ?? [
|
|
42
38
|
`arn:aws:secretsmanager:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:secret:*`,
|
|
43
39
|
],
|
|
@@ -46,59 +42,58 @@ export class IamManager {
|
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
44
|
* @summary Method to create iam statement to put events
|
|
49
|
-
* @param
|
|
45
|
+
* @param resourceArns list of ARNs to allow access to
|
|
50
46
|
*/
|
|
51
47
|
public statementForPutEvents(resourceArns?: string[]) {
|
|
52
48
|
return new iam.PolicyStatement({
|
|
53
|
-
effect: iam.Effect.ALLOW,
|
|
54
49
|
actions: ['events:PutEvents'],
|
|
50
|
+
effect: iam.Effect.ALLOW,
|
|
55
51
|
resources: resourceArns ?? ['*'],
|
|
56
52
|
})
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
/**
|
|
60
56
|
* @summary Method to create iam statement to start stepfunction execution
|
|
61
|
-
* @param
|
|
57
|
+
* @param resourceArns list of ARNs to allow access to
|
|
62
58
|
*/
|
|
63
59
|
public statementForStartExecution(resourceArns?: string[]) {
|
|
64
60
|
return new iam.PolicyStatement({
|
|
65
|
-
effect: iam.Effect.ALLOW,
|
|
66
61
|
actions: ['states:StartExecution'],
|
|
62
|
+
effect: iam.Effect.ALLOW,
|
|
67
63
|
resources: resourceArns ?? ['*'],
|
|
68
64
|
})
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
/**
|
|
72
68
|
* @summary Method to create iam statement to poll queue
|
|
73
|
-
* @param
|
|
69
|
+
* @param resourceArns list of ARNs to allow access to
|
|
74
70
|
*/
|
|
75
71
|
public statementForPollQueue(resourceArns?: string[]) {
|
|
76
72
|
return new iam.PolicyStatement({
|
|
77
|
-
effect: iam.Effect.ALLOW,
|
|
78
73
|
actions: ['sqs:ReceiveMessage', 'sqs:DeleteMessage', 'sqs:GetQueueAttributes'],
|
|
74
|
+
effect: iam.Effect.ALLOW,
|
|
79
75
|
resources: resourceArns ?? ['*'],
|
|
80
76
|
})
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
/**
|
|
84
80
|
* @summary Method to create iam statement to invoke lambda function
|
|
85
|
-
* @param
|
|
81
|
+
* @param resourceArns list of ARNs to allow access to
|
|
86
82
|
*/
|
|
87
83
|
public statementForInvokeLambda(resourceArns?: string[]) {
|
|
88
84
|
return new iam.PolicyStatement({
|
|
89
|
-
effect: iam.Effect.ALLOW,
|
|
90
85
|
actions: ['lambda:InvokeFunction'],
|
|
86
|
+
effect: iam.Effect.ALLOW,
|
|
91
87
|
resources: resourceArns ?? ['*'],
|
|
92
88
|
})
|
|
93
89
|
}
|
|
94
90
|
|
|
95
91
|
/**
|
|
96
92
|
* @summary Method to create iam statement to read app config
|
|
97
|
-
* @param
|
|
93
|
+
* @param resourceArns list of ARNs to allow access to
|
|
98
94
|
*/
|
|
99
95
|
public statementForReadAnyAppConfig(resourceArns?: string[]) {
|
|
100
96
|
return new iam.PolicyStatement({
|
|
101
|
-
effect: iam.Effect.ALLOW,
|
|
102
97
|
actions: [
|
|
103
98
|
'ssm:GetDocument',
|
|
104
99
|
'ssm:ListDocuments',
|
|
@@ -113,152 +108,153 @@ export class IamManager {
|
|
|
113
108
|
'appconfig:GetConfiguration',
|
|
114
109
|
'appconfig:ListDeployments',
|
|
115
110
|
],
|
|
111
|
+
effect: iam.Effect.ALLOW,
|
|
116
112
|
resources: resourceArns ?? ['*'],
|
|
117
113
|
})
|
|
118
114
|
}
|
|
119
115
|
|
|
120
116
|
/**
|
|
121
117
|
* @summary Method to create iam statement to access app config
|
|
122
|
-
* @param
|
|
118
|
+
* @param resourceArns list of ARNs to allow access to
|
|
123
119
|
*/
|
|
124
120
|
public statementForAppConfigExecution(resourceArns?: string[]) {
|
|
125
121
|
return new iam.PolicyStatement({
|
|
126
|
-
effect: iam.Effect.ALLOW,
|
|
127
122
|
actions: ['appconfig:GetLatestConfiguration', 'appconfig:StartConfigurationSession'],
|
|
123
|
+
effect: iam.Effect.ALLOW,
|
|
128
124
|
resources: resourceArns ?? ['*'],
|
|
129
125
|
})
|
|
130
126
|
}
|
|
131
127
|
|
|
132
128
|
/**
|
|
133
129
|
* @summary Method to create iam statement to put xray telemetry
|
|
134
|
-
* @param
|
|
130
|
+
* @param resourceArns list of ARNs to allow access to
|
|
135
131
|
*/
|
|
136
132
|
public statementForPutXrayTelemetry(resourceArns?: string[]) {
|
|
137
133
|
return new iam.PolicyStatement({
|
|
138
|
-
effect: iam.Effect.ALLOW,
|
|
139
134
|
actions: ['xray:PutTraceSegments', 'xray:PutTelemetryRecords'],
|
|
135
|
+
effect: iam.Effect.ALLOW,
|
|
140
136
|
resources: resourceArns ?? ['*'],
|
|
141
137
|
})
|
|
142
138
|
}
|
|
143
139
|
|
|
144
140
|
/**
|
|
145
141
|
* @summary Method to create iam statement to decrypt kms
|
|
146
|
-
* @param
|
|
142
|
+
* @param resourceArns list of ARNs to allow access to
|
|
147
143
|
*/
|
|
148
144
|
public statementForDecryptKms(resourceArns?: string[]) {
|
|
149
145
|
return new iam.PolicyStatement({
|
|
150
|
-
effect: iam.Effect.ALLOW,
|
|
151
146
|
actions: ['kms:Decrypt'],
|
|
147
|
+
effect: iam.Effect.ALLOW,
|
|
152
148
|
resources: resourceArns ?? ['*'],
|
|
153
149
|
})
|
|
154
150
|
}
|
|
155
151
|
|
|
156
152
|
/**
|
|
157
153
|
* @summary Method to create iam statement to list s3 buckets
|
|
158
|
-
* @param
|
|
159
|
-
* @param
|
|
154
|
+
* @param scope scope in which this resource is defined
|
|
155
|
+
* @param bucket
|
|
160
156
|
*/
|
|
161
157
|
public statementForListBucket(scope: CommonConstruct, bucket: s3.IBucket) {
|
|
162
158
|
return new iam.PolicyStatement({
|
|
163
|
-
effect: iam.Effect.ALLOW,
|
|
164
159
|
actions: ['s3:ListBucket'],
|
|
160
|
+
effect: iam.Effect.ALLOW,
|
|
165
161
|
resources: [bucket.bucketArn],
|
|
166
162
|
})
|
|
167
163
|
}
|
|
168
164
|
|
|
169
165
|
/**
|
|
170
166
|
* @summary Method to create iam statement to list all s3 buckets
|
|
171
|
-
* @param
|
|
167
|
+
* @param resourceArns list of ARNs to allow access to
|
|
172
168
|
*/
|
|
173
169
|
public statementForListAllMyBuckets(resourceArns?: string[]) {
|
|
174
170
|
return new iam.PolicyStatement({
|
|
175
|
-
effect: iam.Effect.ALLOW,
|
|
176
171
|
actions: ['s3:ListAllMyBuckets'],
|
|
172
|
+
effect: iam.Effect.ALLOW,
|
|
177
173
|
resources: resourceArns ?? ['*'],
|
|
178
174
|
})
|
|
179
175
|
}
|
|
180
176
|
|
|
181
177
|
/**
|
|
182
178
|
* @summary Method to create iam statement to get s3 objects in buckets
|
|
183
|
-
* @param
|
|
184
|
-
* @param
|
|
185
|
-
* @param
|
|
179
|
+
* @param scope scope in which this resource is defined
|
|
180
|
+
* @param bucket
|
|
181
|
+
* @param resourceArns list of ARNs to allow access to
|
|
186
182
|
*/
|
|
187
183
|
public statementForGetAnyS3Objects(scope: CommonConstruct, bucket: s3.IBucket, resourceArns?: string[]) {
|
|
188
184
|
return new iam.PolicyStatement({
|
|
189
|
-
effect: iam.Effect.ALLOW,
|
|
190
185
|
actions: ['s3:GetObject', 's3:GetObjectAcl'],
|
|
186
|
+
effect: iam.Effect.ALLOW,
|
|
191
187
|
resources: resourceArns ?? [bucket.arnForObjects(`*`)],
|
|
192
188
|
})
|
|
193
189
|
}
|
|
194
190
|
|
|
195
191
|
/**
|
|
196
192
|
* @summary Method to create iam statement to delete s3 objects in buckets
|
|
197
|
-
* @param
|
|
198
|
-
* @param
|
|
199
|
-
* @param
|
|
193
|
+
* @param scope scope in which this resource is defined
|
|
194
|
+
* @param bucket
|
|
195
|
+
* @param resourceArns list of ARNs to allow access to
|
|
200
196
|
*/
|
|
201
197
|
public statementForDeleteAnyS3Objects(scope: CommonConstruct, bucket: s3.IBucket, resourceArns?: string[]) {
|
|
202
198
|
return new iam.PolicyStatement({
|
|
203
|
-
effect: iam.Effect.ALLOW,
|
|
204
199
|
actions: ['s3:DeleteObject'],
|
|
200
|
+
effect: iam.Effect.ALLOW,
|
|
205
201
|
resources: resourceArns ?? [bucket.arnForObjects(`*`)],
|
|
206
202
|
})
|
|
207
203
|
}
|
|
208
204
|
|
|
209
205
|
/**
|
|
210
206
|
* @summary Method to create iam statement to write s3 objects in buckets
|
|
211
|
-
* @param
|
|
212
|
-
* @param
|
|
213
|
-
* @param
|
|
207
|
+
* @param scope scope in which this resource is defined
|
|
208
|
+
* @param bucket
|
|
209
|
+
* @param resourceArns list of ARNs to allow access to
|
|
214
210
|
*/
|
|
215
211
|
public statementForPutAnyS3Objects(scope: CommonConstruct, bucket: s3.IBucket, resourceArns?: string[]) {
|
|
216
212
|
return new iam.PolicyStatement({
|
|
217
|
-
effect: iam.Effect.ALLOW,
|
|
218
213
|
actions: ['s3:PutObject', 's3:PutObjectAcl'],
|
|
214
|
+
effect: iam.Effect.ALLOW,
|
|
219
215
|
resources: resourceArns ?? [bucket.arnForObjects(`*`)],
|
|
220
216
|
})
|
|
221
217
|
}
|
|
222
218
|
|
|
223
219
|
/**
|
|
224
220
|
* @summary Method to create iam statement to pass iam role
|
|
225
|
-
* @param
|
|
221
|
+
* @param resourceArns list of ARNs to allow access to
|
|
226
222
|
*/
|
|
227
223
|
public statementForPassRole(resourceArns?: string[]) {
|
|
228
224
|
return new iam.PolicyStatement({
|
|
229
|
-
effect: iam.Effect.ALLOW,
|
|
230
225
|
actions: ['iam:PassRole'],
|
|
226
|
+
effect: iam.Effect.ALLOW,
|
|
231
227
|
resources: resourceArns ?? ['*'],
|
|
232
228
|
})
|
|
233
229
|
}
|
|
234
230
|
|
|
235
231
|
/**
|
|
236
232
|
* @summary Method to create iam statement to invalidate cloudfront cache
|
|
237
|
-
* @param
|
|
233
|
+
* @param resourceArns list of ARNs to allow access to
|
|
238
234
|
*/
|
|
239
235
|
public statementForCloudfrontInvalidation(resourceArns?: string[]) {
|
|
240
236
|
return new iam.PolicyStatement({
|
|
241
|
-
effect: iam.Effect.ALLOW,
|
|
242
237
|
actions: ['cloudfront:GetInvalidation', 'cloudfront:CreateInvalidation'],
|
|
238
|
+
effect: iam.Effect.ALLOW,
|
|
243
239
|
resources: resourceArns ?? ['*'],
|
|
244
240
|
})
|
|
245
241
|
}
|
|
246
242
|
|
|
247
243
|
/**
|
|
248
244
|
* @summary Method to create iam statement to access efs
|
|
249
|
-
* @param
|
|
245
|
+
* @param resourceArns list of ARNs to allow access to
|
|
250
246
|
*/
|
|
251
247
|
public statementForWriteEfs(resourceArns?: string[]) {
|
|
252
248
|
return new iam.PolicyStatement({
|
|
253
|
-
effect: iam.Effect.ALLOW,
|
|
254
249
|
actions: ['elasticfilesystem:*'],
|
|
250
|
+
effect: iam.Effect.ALLOW,
|
|
255
251
|
resources: resourceArns ?? ['*'],
|
|
256
252
|
})
|
|
257
253
|
}
|
|
258
254
|
|
|
259
255
|
/**
|
|
260
256
|
* @summary Method to create iam policy to invalidate cloudfront cache
|
|
261
|
-
* @param
|
|
257
|
+
* @param resourceArns list of ARNs to allow access to
|
|
262
258
|
*/
|
|
263
259
|
public policyForCloudfrontInvalidation(resourceArns?: string[]) {
|
|
264
260
|
return new iam.PolicyDocument({
|
|
@@ -267,13 +263,13 @@ export class IamManager {
|
|
|
267
263
|
this.statementForPutAnyLogEvent(),
|
|
268
264
|
this.statementForCloudfrontInvalidation(),
|
|
269
265
|
new iam.PolicyStatement({
|
|
270
|
-
effect: iam.Effect.ALLOW,
|
|
271
266
|
actions: [
|
|
272
267
|
'ecr:GetDownloadUrlForLayer',
|
|
273
268
|
'ecr:BatchGetImage',
|
|
274
269
|
'ecr:BatchCheckLayerAvailability',
|
|
275
270
|
'ecr:GetAuthorizationToken',
|
|
276
271
|
],
|
|
272
|
+
effect: iam.Effect.ALLOW,
|
|
277
273
|
resources: resourceArns ?? ['*'],
|
|
278
274
|
}),
|
|
279
275
|
],
|
|
@@ -282,8 +278,8 @@ export class IamManager {
|
|
|
282
278
|
|
|
283
279
|
/**
|
|
284
280
|
* @summary Method to create iam role to invalidate cloudfront cache
|
|
285
|
-
* @param
|
|
286
|
-
* @param
|
|
281
|
+
* @param id scoped id of the resource
|
|
282
|
+
* @param scope scope in which this resource is defined
|
|
287
283
|
*/
|
|
288
284
|
public roleForCloudfrontInvalidation(id: string, scope: CommonConstruct) {
|
|
289
285
|
return new iam.Role(scope, `${id}-install-deps-project-role`, {
|
|
@@ -296,54 +292,54 @@ export class IamManager {
|
|
|
296
292
|
|
|
297
293
|
/**
|
|
298
294
|
* @summary Method to create iam statement to assume iam role
|
|
299
|
-
* @param
|
|
300
|
-
* @param
|
|
295
|
+
* @param scope scope in which this resource is defined
|
|
296
|
+
* @param servicePrincipals
|
|
301
297
|
*/
|
|
302
298
|
public statementForAssumeRole(scope: CommonConstruct, servicePrincipals: iam.ServicePrincipal[]) {
|
|
303
299
|
return new iam.PolicyStatement({
|
|
304
|
-
effect: iam.Effect.ALLOW,
|
|
305
300
|
actions: ['sts:AssumeRole'],
|
|
301
|
+
effect: iam.Effect.ALLOW,
|
|
306
302
|
principals: servicePrincipals,
|
|
307
303
|
})
|
|
308
304
|
}
|
|
309
305
|
|
|
310
306
|
/**
|
|
311
307
|
* @summary Method to create iam statement to pass ecs role
|
|
312
|
-
* @param
|
|
308
|
+
* @param resourceArns list of ARNs to allow access to
|
|
313
309
|
*/
|
|
314
310
|
public statementForEcsPassRole(resourceArns?: string[]) {
|
|
315
311
|
return new iam.PolicyStatement({
|
|
316
|
-
effect: iam.Effect.ALLOW,
|
|
317
312
|
actions: ['iam:PassRole'],
|
|
318
|
-
resources: resourceArns ?? ['*'],
|
|
319
313
|
conditions: { StringLike: { 'iam:PassedToService': 'ecs-tasks.amazonaws.com' } },
|
|
314
|
+
effect: iam.Effect.ALLOW,
|
|
315
|
+
resources: resourceArns ?? ['*'],
|
|
320
316
|
})
|
|
321
317
|
}
|
|
322
318
|
|
|
323
319
|
/**
|
|
324
320
|
* @summary Method to create iam statement to run ecs task
|
|
325
|
-
* @param
|
|
326
|
-
* @param
|
|
327
|
-
* @param
|
|
321
|
+
* @param scope scope in which this resource is defined
|
|
322
|
+
* @param cluster
|
|
323
|
+
* @param task
|
|
328
324
|
*/
|
|
329
325
|
public statementForRunEcsTask(scope: CommonConstruct, cluster: ecs.ICluster, task: ecs.ITaskDefinition) {
|
|
330
326
|
return new iam.PolicyStatement({
|
|
331
|
-
effect: iam.Effect.ALLOW,
|
|
332
327
|
actions: ['ecs:RunTask'],
|
|
333
|
-
resources: [task.taskDefinitionArn],
|
|
334
328
|
conditions: { ArnLike: { 'ecs:cluster': cluster.clusterArn } },
|
|
329
|
+
effect: iam.Effect.ALLOW,
|
|
330
|
+
resources: [task.taskDefinitionArn],
|
|
335
331
|
})
|
|
336
332
|
}
|
|
337
333
|
|
|
338
334
|
/**
|
|
339
335
|
* @summary Method to create iam statement to create log stream
|
|
340
|
-
* @param
|
|
341
|
-
* @param
|
|
336
|
+
* @param scope scope in which this resource is defined
|
|
337
|
+
* @param logGroup
|
|
342
338
|
*/
|
|
343
339
|
public statementForCreateLogStream(scope: CommonConstruct, logGroup: logs.CfnLogGroup) {
|
|
344
340
|
return new iam.PolicyStatement({
|
|
345
|
-
effect: iam.Effect.ALLOW,
|
|
346
341
|
actions: ['logs:CreateLogStream'],
|
|
342
|
+
effect: iam.Effect.ALLOW,
|
|
347
343
|
resources: [
|
|
348
344
|
`arn:aws:logs:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:log-group:${
|
|
349
345
|
logGroup.logGroupName
|
|
@@ -355,25 +351,25 @@ export class IamManager {
|
|
|
355
351
|
|
|
356
352
|
/**
|
|
357
353
|
* @summary Method to create iam statement to create any log stream
|
|
358
|
-
* @param
|
|
354
|
+
* @param resourceArns list of ARNs to allow access to
|
|
359
355
|
*/
|
|
360
356
|
public statementForCreateAnyLogStream(resourceArns?: string[]) {
|
|
361
357
|
return new iam.PolicyStatement({
|
|
362
|
-
effect: iam.Effect.ALLOW,
|
|
363
358
|
actions: ['logs:CreateLogStream'],
|
|
359
|
+
effect: iam.Effect.ALLOW,
|
|
364
360
|
resources: resourceArns ?? ['*'],
|
|
365
361
|
})
|
|
366
362
|
}
|
|
367
363
|
|
|
368
364
|
/**
|
|
369
365
|
* @summary Method to create iam statement to write log events
|
|
370
|
-
* @param
|
|
371
|
-
* @param
|
|
366
|
+
* @param scope scope in which this resource is defined
|
|
367
|
+
* @param logGroup
|
|
372
368
|
*/
|
|
373
369
|
public statementForPutLogEvent(scope: CommonConstruct, logGroup: logs.CfnLogGroup) {
|
|
374
370
|
return new iam.PolicyStatement({
|
|
375
|
-
effect: iam.Effect.ALLOW,
|
|
376
371
|
actions: ['logs:PutLogEvents'],
|
|
372
|
+
effect: iam.Effect.ALLOW,
|
|
377
373
|
resources: [
|
|
378
374
|
`arn:aws:logs:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:log-group:${
|
|
379
375
|
logGroup.logGroupName
|
|
@@ -385,23 +381,22 @@ export class IamManager {
|
|
|
385
381
|
|
|
386
382
|
/**
|
|
387
383
|
* @summary Method to create iam statement to write any log events
|
|
388
|
-
* @param
|
|
384
|
+
* @param resourceArns list of ARNs to allow access to
|
|
389
385
|
*/
|
|
390
386
|
public statementForPutAnyLogEvent(resourceArns?: string[]) {
|
|
391
387
|
return new iam.PolicyStatement({
|
|
392
|
-
effect: iam.Effect.ALLOW,
|
|
393
388
|
actions: ['logs:PutLogEvents'],
|
|
389
|
+
effect: iam.Effect.ALLOW,
|
|
394
390
|
resources: resourceArns ?? ['*'],
|
|
395
391
|
})
|
|
396
392
|
}
|
|
397
393
|
|
|
398
394
|
/**
|
|
399
395
|
* @summary Method to create iam statement to read items from dynamodb table
|
|
400
|
-
* @param
|
|
396
|
+
* @param resourceArns list of ARNs to allow access to
|
|
401
397
|
*/
|
|
402
398
|
public statementForReadTableItems(resourceArns?: string[]) {
|
|
403
399
|
return new iam.PolicyStatement({
|
|
404
|
-
effect: iam.Effect.ALLOW,
|
|
405
400
|
actions: [
|
|
406
401
|
'dynamodb:PartiQLSelect',
|
|
407
402
|
'dynamodb:DescribeTable',
|
|
@@ -412,27 +407,28 @@ export class IamManager {
|
|
|
412
407
|
'dynamodb:GetRecords',
|
|
413
408
|
'dynamodb:BatchGetItem',
|
|
414
409
|
],
|
|
410
|
+
effect: iam.Effect.ALLOW,
|
|
415
411
|
resources: resourceArns ?? ['*'],
|
|
416
412
|
})
|
|
417
413
|
}
|
|
418
414
|
|
|
419
415
|
/**
|
|
420
416
|
* @summary Method to create iam statement to write items from dynamodb table
|
|
421
|
-
* @param
|
|
417
|
+
* @param resourceArns list of ARNs to allow access to
|
|
422
418
|
*/
|
|
423
419
|
public statementForWriteTableItems(resourceArns?: string[]) {
|
|
424
420
|
return new iam.PolicyStatement({
|
|
425
|
-
effect: iam.Effect.ALLOW,
|
|
426
421
|
actions: ['dynamodb:BatchWriteItem', 'dynamodb:DeleteItem', 'dynamodb:PutItem', 'dynamodb:UpdateItem'],
|
|
422
|
+
effect: iam.Effect.ALLOW,
|
|
427
423
|
resources: resourceArns ?? ['*'],
|
|
428
424
|
})
|
|
429
425
|
}
|
|
430
426
|
|
|
431
427
|
/**
|
|
432
428
|
* @summary Method to create iam statement for cloud trail
|
|
433
|
-
* @param
|
|
434
|
-
* @param
|
|
435
|
-
* @param
|
|
429
|
+
* @param id scoped id of the resource
|
|
430
|
+
* @param scope scope in which this resource is defined
|
|
431
|
+
* @param logGroup
|
|
436
432
|
*/
|
|
437
433
|
public createRoleForCloudTrail(id: string, scope: CommonConstruct, logGroup: logs.CfnLogGroup) {
|
|
438
434
|
const policy = new iam.PolicyDocument({
|
|
@@ -444,8 +440,8 @@ export class IamManager {
|
|
|
444
440
|
}),
|
|
445
441
|
policies: [
|
|
446
442
|
{
|
|
447
|
-
policyName: `${id}-policy-${scope.props.stage}`,
|
|
448
443
|
policyDocument: policy,
|
|
444
|
+
policyName: `${id}-policy-${scope.props.stage}`,
|
|
449
445
|
},
|
|
450
446
|
],
|
|
451
447
|
roleName: `${id}-${scope.props.stage}`,
|
|
@@ -459,10 +455,10 @@ export class IamManager {
|
|
|
459
455
|
|
|
460
456
|
/**
|
|
461
457
|
* @summary Method to create iam statement for ecs event
|
|
462
|
-
* @param
|
|
463
|
-
* @param
|
|
464
|
-
* @param
|
|
465
|
-
* @param
|
|
458
|
+
* @param id scoped id of the resource
|
|
459
|
+
* @param scope scope in which this resource is defined
|
|
460
|
+
* @param cluster
|
|
461
|
+
* @param task
|
|
466
462
|
*/
|
|
467
463
|
public createRoleForEcsEvent(id: string, scope: CommonConstruct, cluster: ecs.ICluster, task: ecs.ITaskDefinition) {
|
|
468
464
|
const policy = new iam.PolicyDocument({
|
|
@@ -484,9 +480,9 @@ export class IamManager {
|
|
|
484
480
|
|
|
485
481
|
/**
|
|
486
482
|
* @summary Method to create iam statement for ecs execution
|
|
487
|
-
* @param
|
|
488
|
-
* @param
|
|
489
|
-
* @param
|
|
483
|
+
* @param id scoped id of the resource
|
|
484
|
+
* @param scope scope in which this resource is defined
|
|
485
|
+
* @param policy
|
|
490
486
|
*/
|
|
491
487
|
public createRoleForEcsExecution(id: string, scope: CommonConstruct, policy: iam.PolicyDocument) {
|
|
492
488
|
const role = new iam.Role(scope, `${id}`, {
|
|
@@ -511,10 +507,10 @@ export class IamManager {
|
|
|
511
507
|
|
|
512
508
|
/**
|
|
513
509
|
* @summary Method to create iam statement for lambda execution
|
|
514
|
-
* @param
|
|
515
|
-
* @param
|
|
516
|
-
* @param
|
|
517
|
-
* @param
|
|
510
|
+
* @param id scoped id of the resource
|
|
511
|
+
* @param scope scope in which this resource is defined
|
|
512
|
+
* @param policy
|
|
513
|
+
* @param servicePrinicpal
|
|
518
514
|
*/
|
|
519
515
|
public createRoleForLambda(
|
|
520
516
|
id: string,
|
|
@@ -544,10 +540,10 @@ export class IamManager {
|
|
|
544
540
|
|
|
545
541
|
/**
|
|
546
542
|
* @summary Method to create iam statement for step function execution
|
|
547
|
-
* @param
|
|
548
|
-
* @param
|
|
549
|
-
* @param
|
|
550
|
-
* @param
|
|
543
|
+
* @param id scoped id of the resource
|
|
544
|
+
* @param scope scope in which this resource is defined
|
|
545
|
+
* @param policy
|
|
546
|
+
* @param servicePrinicpal
|
|
551
547
|
*/
|
|
552
548
|
public createRoleForStepFunction(
|
|
553
549
|
id: string,
|
|
@@ -577,10 +573,10 @@ export class IamManager {
|
|
|
577
573
|
|
|
578
574
|
/**
|
|
579
575
|
* @summary Method to create iam statement for sqs to step function pipe
|
|
580
|
-
* @param
|
|
581
|
-
* @param
|
|
582
|
-
* @param
|
|
583
|
-
* @param
|
|
576
|
+
* @param id scoped id of the resource
|
|
577
|
+
* @param scope scope in which this resource is defined
|
|
578
|
+
* @param queueArn the arn of the sqs queue
|
|
579
|
+
* @param stepFunctionArn the arn of the step function
|
|
584
580
|
*/
|
|
585
581
|
public createRoleForSqsToSfnPipe(id: string, scope: CommonConstruct, queueArn: string, stepFunctionArn: string) {
|
|
586
582
|
const role = new iam.Role(scope, `${id}`, {
|
|
@@ -600,8 +596,8 @@ export class IamManager {
|
|
|
600
596
|
|
|
601
597
|
/**
|
|
602
598
|
* @summary Method to create iam policy for sqs
|
|
603
|
-
* @param
|
|
604
|
-
* @param
|
|
599
|
+
* @param id scoped id of the resource
|
|
600
|
+
* @param scope scope in which this resource is defined
|
|
605
601
|
* @param sqsQueue
|
|
606
602
|
* @param eventBridgeRule
|
|
607
603
|
* @param servicePrincipals
|
|
@@ -617,12 +613,12 @@ export class IamManager {
|
|
|
617
613
|
statements: [
|
|
618
614
|
new iam.PolicyStatement({
|
|
619
615
|
actions: ['sqs:*'],
|
|
620
|
-
effect: iam.Effect.ALLOW,
|
|
621
616
|
conditions: {
|
|
622
617
|
ArnEquals: {
|
|
623
618
|
'aws:SourceArn': eventBridgeRule,
|
|
624
619
|
},
|
|
625
620
|
},
|
|
621
|
+
effect: iam.Effect.ALLOW,
|
|
626
622
|
principals: servicePrincipals ?? [new iam.ServicePrincipal('events.amazonaws.com')],
|
|
627
623
|
resources: [sqsQueue.queueArn],
|
|
628
624
|
}),
|
|
@@ -4,9 +4,6 @@ import { CommonConstruct } from '../../../common'
|
|
|
4
4
|
import { KmsKeyProps } from './types'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @stability stable
|
|
8
|
-
* @category cdk-utils.kms-manager
|
|
9
|
-
* @subcategory Construct
|
|
10
7
|
* @classdesc Provides operations on AWS KMS.
|
|
11
8
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
12
9
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -20,30 +17,29 @@ import { KmsKeyProps } from './types'
|
|
|
20
17
|
* this.kms.createKey('MyKey', this)
|
|
21
18
|
* }
|
|
22
19
|
* }
|
|
23
|
-
*
|
|
24
20
|
* @see [CDK KMS Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kms-readme.html}
|
|
25
21
|
*/
|
|
26
22
|
export class KmsManager {
|
|
27
23
|
/**
|
|
28
24
|
* @summary Method to create a KMS key
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
25
|
+
* @param id scoped id of the resource
|
|
26
|
+
* @param scope scope in which this resource is defined
|
|
27
|
+
* @param props KMS key props
|
|
32
28
|
*/
|
|
33
29
|
public createKey(id: string, scope: CommonConstruct, props: KmsKeyProps) {
|
|
34
30
|
if (!props) throw `KMS Key props undefined for ${id}`
|
|
35
31
|
|
|
36
32
|
const key = new kms.Key(scope, `${id}`, {
|
|
37
|
-
|
|
33
|
+
admins: props.admins,
|
|
38
34
|
alias: `${props.alias}-${scope.props.stage}`,
|
|
35
|
+
description: props.description,
|
|
39
36
|
enableKeyRotation: props.enableKeyRotation,
|
|
40
37
|
enabled: props.enabled,
|
|
41
38
|
keySpec: props.keySpec,
|
|
42
39
|
keyUsage: props.keyUsage,
|
|
40
|
+
pendingWindow: props.pendingWindow,
|
|
43
41
|
policy: props.policy,
|
|
44
|
-
admins: props.admins,
|
|
45
42
|
removalPolicy: props.removalPolicy,
|
|
46
|
-
pendingWindow: props.pendingWindow,
|
|
47
43
|
})
|
|
48
44
|
|
|
49
45
|
utils.createCfnOutput(`${id}-keyId`, scope, key.keyId)
|