@gradientedge/cdk-utils 9.9.0 → 9.10.1
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/dist/src/lib/aws/common/construct.d.ts +8 -1
- package/dist/src/lib/aws/common/construct.js +14 -0
- package/dist/src/lib/aws/common/stack.d.ts +3 -0
- package/dist/src/lib/aws/common/stack.js +3 -0
- package/dist/src/lib/aws/common/types.d.ts +8 -0
- package/dist/src/lib/aws/construct/api-to-any-target/main.js +3 -1
- package/dist/src/lib/aws/construct/api-to-any-target/types.d.ts +3 -3
- package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +9 -6
- package/dist/src/lib/aws/construct/api-to-eventbridge-target/types.d.ts +6 -6
- package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +4 -2
- package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +2 -2
- package/dist/src/lib/aws/construct/application-configuration/main.js +1 -1
- package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +4 -5
- package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +13 -9
- package/dist/src/lib/aws/construct/site-with-lambda-backend/main.js +9 -3
- package/dist/src/lib/aws/services/api-gateway/main.js +3 -1
- package/dist/src/lib/aws/services/api-gateway/types.d.ts +6 -1
- package/dist/src/lib/aws/services/appconfig/main.js +2 -2
- package/dist/src/lib/aws/services/appconfig/types.d.ts +2 -0
- package/dist/src/lib/aws/services/cloudfront/main.js +8 -2
- package/dist/src/lib/aws/services/cloudfront/types.d.ts +2 -0
- package/dist/src/lib/aws/services/cloudtrail/main.js +3 -1
- package/dist/src/lib/aws/services/cloudtrail/types.d.ts +2 -0
- package/dist/src/lib/aws/services/dynamodb/main.js +3 -1
- package/dist/src/lib/aws/services/dynamodb/types.d.ts +2 -0
- package/dist/src/lib/aws/services/elastic-container-service/main.js +6 -2
- package/dist/src/lib/aws/services/elastic-container-service/types.d.ts +2 -0
- package/dist/src/lib/aws/services/elastic-file-system/main.js +3 -1
- package/dist/src/lib/aws/services/elastic-file-system/types.d.ts +3 -1
- package/dist/src/lib/aws/services/elastic-kubernetes-service/main.js +3 -1
- package/dist/src/lib/aws/services/elastic-kubernetes-service/types.d.ts +2 -0
- package/dist/src/lib/aws/services/elasticache/main.js +3 -1
- package/dist/src/lib/aws/services/elasticache/types.d.ts +2 -0
- package/dist/src/lib/aws/services/eventbridge/main.js +38 -9
- package/dist/src/lib/aws/services/eventbridge/types.d.ts +9 -1
- package/dist/src/lib/aws/services/evidently/main.js +22 -4
- package/dist/src/lib/aws/services/evidently/types.d.ts +5 -0
- package/dist/src/lib/aws/services/identity-access-management/main.js +10 -10
- package/dist/src/lib/aws/services/lambda/main.js +6 -2
- package/dist/src/lib/aws/services/lambda/types.d.ts +5 -2
- package/dist/src/lib/aws/services/secrets-manager/index.d.ts +1 -0
- package/dist/src/lib/aws/services/secrets-manager/index.js +1 -0
- package/dist/src/lib/aws/services/secrets-manager/main.d.ts +3 -2
- package/dist/src/lib/aws/services/secrets-manager/main.js +5 -1
- package/dist/src/lib/aws/services/secrets-manager/types.d.ts +5 -0
- package/dist/src/lib/aws/services/secrets-manager/types.js +2 -0
- package/dist/src/lib/aws/services/simple-notification-service/main.js +8 -4
- package/dist/src/lib/aws/services/simple-notification-service/types.d.ts +2 -0
- package/dist/src/lib/aws/services/simple-queue-service/main.js +9 -7
- package/dist/src/lib/aws/services/simple-queue-service/types.d.ts +2 -0
- package/dist/src/lib/aws/services/simple-storage-service/main.d.ts +1 -1
- package/dist/src/lib/aws/services/simple-storage-service/main.js +12 -8
- package/dist/src/lib/aws/services/simple-storage-service/types.d.ts +3 -1
- package/dist/src/lib/aws/services/step-function/main.js +3 -1
- package/dist/src/lib/aws/services/step-function/types.d.ts +2 -0
- package/dist/src/lib/aws/services/virtual-private-cloud/main.js +10 -3
- package/dist/src/lib/aws/services/virtual-private-cloud/types.d.ts +2 -0
- package/dist/src/lib/aws/services/web-application-firewall/main.js +6 -2
- package/dist/src/lib/aws/services/web-application-firewall/types.d.ts +3 -0
- package/package.json +2 -2
- package/src/lib/aws/common/construct.ts +16 -1
- package/src/lib/aws/common/stack.ts +3 -0
- package/src/lib/aws/common/types.ts +9 -0
- package/src/lib/aws/construct/api-to-any-target/main.ts +6 -1
- package/src/lib/aws/construct/api-to-any-target/types.ts +2 -3
- package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +13 -6
- package/src/lib/aws/construct/api-to-eventbridge-target/types.ts +6 -7
- package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +7 -2
- package/src/lib/aws/construct/api-to-lambda-target/main.ts +2 -2
- package/src/lib/aws/construct/application-configuration/main.ts +1 -1
- package/src/lib/aws/construct/lambda-with-iam-access/main.ts +5 -5
- package/src/lib/aws/construct/site-with-ecs-backend/main.ts +15 -9
- package/src/lib/aws/construct/site-with-lambda-backend/main.ts +11 -3
- package/src/lib/aws/services/api-gateway/main.ts +3 -1
- package/src/lib/aws/services/api-gateway/types.ts +7 -1
- package/src/lib/aws/services/appconfig/main.ts +2 -2
- package/src/lib/aws/services/appconfig/types.ts +2 -0
- package/src/lib/aws/services/cloudfront/main.ts +6 -2
- package/src/lib/aws/services/cloudfront/types.ts +2 -0
- package/src/lib/aws/services/cloudtrail/main.ts +2 -1
- package/src/lib/aws/services/cloudtrail/types.ts +4 -1
- package/src/lib/aws/services/dynamodb/main.ts +2 -1
- package/src/lib/aws/services/dynamodb/types.ts +4 -1
- package/src/lib/aws/services/elastic-container-service/main.ts +4 -2
- package/src/lib/aws/services/elastic-container-service/types.ts +2 -0
- package/src/lib/aws/services/elastic-file-system/main.ts +2 -1
- package/src/lib/aws/services/elastic-file-system/types.ts +3 -1
- package/src/lib/aws/services/elastic-kubernetes-service/main.ts +2 -1
- package/src/lib/aws/services/elastic-kubernetes-service/types.ts +2 -0
- package/src/lib/aws/services/elasticache/main.ts +2 -1
- package/src/lib/aws/services/elasticache/types.ts +4 -1
- package/src/lib/aws/services/eventbridge/main.ts +32 -9
- package/src/lib/aws/services/eventbridge/types.ts +11 -2
- package/src/lib/aws/services/evidently/main.ts +18 -4
- package/src/lib/aws/services/evidently/types.ts +13 -4
- package/src/lib/aws/services/identity-access-management/main.ts +10 -10
- package/src/lib/aws/services/lambda/main.ts +4 -2
- package/src/lib/aws/services/lambda/types.ts +5 -2
- package/src/lib/aws/services/secrets-manager/index.ts +1 -0
- package/src/lib/aws/services/secrets-manager/main.ts +7 -3
- package/src/lib/aws/services/secrets-manager/types.ts +6 -0
- package/src/lib/aws/services/simple-notification-service/main.ts +6 -4
- package/src/lib/aws/services/simple-notification-service/types.ts +4 -1
- package/src/lib/aws/services/simple-queue-service/main.ts +8 -7
- package/src/lib/aws/services/simple-queue-service/types.ts +2 -0
- package/src/lib/aws/services/simple-storage-service/main.ts +12 -8
- package/src/lib/aws/services/simple-storage-service/types.ts +3 -1
- package/src/lib/aws/services/step-function/main.ts +3 -1
- package/src/lib/aws/services/step-function/types.ts +4 -1
- package/src/lib/aws/services/virtual-private-cloud/main.ts +9 -3
- package/src/lib/aws/services/virtual-private-cloud/types.ts +2 -0
- package/src/lib/aws/services/web-application-firewall/main.ts +4 -2
- package/src/lib/aws/services/web-application-firewall/types.ts +7 -2
|
@@ -461,10 +461,10 @@ export class IamManager {
|
|
|
461
461
|
policies: [
|
|
462
462
|
{
|
|
463
463
|
policyDocument: policy,
|
|
464
|
-
policyName: `${id}-policy
|
|
464
|
+
policyName: scope.resourceNameFormatter(`${id}-policy`),
|
|
465
465
|
},
|
|
466
466
|
],
|
|
467
|
-
roleName:
|
|
467
|
+
roleName: scope.resourceNameFormatter(id),
|
|
468
468
|
})
|
|
469
469
|
|
|
470
470
|
createCfnOutput(`${id}Arn`, scope, role.attrArn)
|
|
@@ -489,7 +489,7 @@ export class IamManager {
|
|
|
489
489
|
assumedBy: new ServicePrincipal('events.amazonaws.com'),
|
|
490
490
|
description: `Role for ${id} ECS Task execution from EventBridge`,
|
|
491
491
|
inlinePolicies: { policy },
|
|
492
|
-
roleName:
|
|
492
|
+
roleName: scope.resourceNameFormatter(id),
|
|
493
493
|
})
|
|
494
494
|
|
|
495
495
|
createCfnOutput(`${id}Arn`, scope, role.roleArn)
|
|
@@ -516,7 +516,7 @@ export class IamManager {
|
|
|
516
516
|
'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy'
|
|
517
517
|
),
|
|
518
518
|
],
|
|
519
|
-
roleName:
|
|
519
|
+
roleName: scope.resourceNameFormatter(id),
|
|
520
520
|
})
|
|
521
521
|
|
|
522
522
|
createCfnOutput(`${id}Arn`, scope, role.roleArn)
|
|
@@ -549,7 +549,7 @@ export class IamManager {
|
|
|
549
549
|
'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
|
|
550
550
|
),
|
|
551
551
|
],
|
|
552
|
-
roleName:
|
|
552
|
+
roleName: scope.resourceNameFormatter(id),
|
|
553
553
|
})
|
|
554
554
|
|
|
555
555
|
createCfnOutput(`${id}Arn`, scope, role.roleArn)
|
|
@@ -575,7 +575,7 @@ export class IamManager {
|
|
|
575
575
|
assumedBy: servicePrincipal ?? new ServicePrincipal('appconfig.amazonaws.com'),
|
|
576
576
|
description: `Role for ${id} AppConfig Secrets`,
|
|
577
577
|
inlinePolicies: { policy },
|
|
578
|
-
roleName:
|
|
578
|
+
roleName: scope.resourceNameFormatter(id),
|
|
579
579
|
})
|
|
580
580
|
|
|
581
581
|
createCfnOutput(`${id}Arn`, scope, role.roleArn)
|
|
@@ -608,7 +608,7 @@ export class IamManager {
|
|
|
608
608
|
'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
|
|
609
609
|
),
|
|
610
610
|
],
|
|
611
|
-
roleName:
|
|
611
|
+
roleName: scope.resourceNameFormatter(id),
|
|
612
612
|
})
|
|
613
613
|
|
|
614
614
|
createCfnOutput(`${id}Arn`, scope, role.roleArn)
|
|
@@ -628,7 +628,7 @@ export class IamManager {
|
|
|
628
628
|
const role = new Role(scope, `${id}`, {
|
|
629
629
|
assumedBy: new ServicePrincipal('pipes.amazonaws.com'),
|
|
630
630
|
description: `Role for ${id} Pipe`,
|
|
631
|
-
roleName:
|
|
631
|
+
roleName: scope.resourceNameFormatter(id),
|
|
632
632
|
})
|
|
633
633
|
|
|
634
634
|
role.addToPolicy(this.statementForPollQueue([queueArn]))
|
|
@@ -651,7 +651,7 @@ export class IamManager {
|
|
|
651
651
|
const role = new Role(scope, `${id}`, {
|
|
652
652
|
assumedBy: new ServicePrincipal('pipes.amazonaws.com'),
|
|
653
653
|
description: `Role for ${id} Pipe`,
|
|
654
|
-
roleName:
|
|
654
|
+
roleName: scope.resourceNameFormatter(id),
|
|
655
655
|
})
|
|
656
656
|
|
|
657
657
|
role.addToPolicy(this.statementForPollQueue([queueArn]))
|
|
@@ -711,7 +711,7 @@ export class IamManager {
|
|
|
711
711
|
const role = new Role(scope, `${id}`, {
|
|
712
712
|
assumedBy: new ServicePrincipal('pipes.amazonaws.com'),
|
|
713
713
|
description: `Role for ${id} Pipe`,
|
|
714
|
-
roleName:
|
|
714
|
+
roleName: scope.resourceNameFormatter(id),
|
|
715
715
|
})
|
|
716
716
|
|
|
717
717
|
role.addToPolicy(this.statementFordynamoDbStream([dynamoDbStreamArn]))
|
|
@@ -108,8 +108,9 @@ export class LambdaManager {
|
|
|
108
108
|
vpcSubnets?: SubnetSelection
|
|
109
109
|
) {
|
|
110
110
|
if (!props) throw `Lambda props undefined for ${id}`
|
|
111
|
+
if (!props.functionName) throw `Lambda functionName undefined for ${id}`
|
|
111
112
|
|
|
112
|
-
const functionName =
|
|
113
|
+
const functionName = scope.resourceNameFormatter(props.functionName, props.resourceNameOptions)
|
|
113
114
|
|
|
114
115
|
let deadLetterQueue
|
|
115
116
|
if (props.deadLetterQueueEnabled) {
|
|
@@ -265,8 +266,9 @@ export class LambdaManager {
|
|
|
265
266
|
vpcSubnets?: SubnetSelection
|
|
266
267
|
) {
|
|
267
268
|
if (!props) throw `Lambda props undefined for ${id}`
|
|
269
|
+
if (!props.functionName) throw `Lambda functionName undefined for ${id}`
|
|
268
270
|
|
|
269
|
-
const functionName =
|
|
271
|
+
const functionName = scope.resourceNameFormatter(props.functionName, props.resourceNameOptions)
|
|
270
272
|
|
|
271
273
|
let deadLetterQueue
|
|
272
274
|
if (props.deadLetterQueueEnabled) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { EdgeFunctionProps } from 'aws-cdk-lib/aws-cloudfront/lib/experimental'
|
|
1
2
|
import { AliasProps, FunctionProps } from 'aws-cdk-lib/aws-lambda'
|
|
3
|
+
import { SqsEventSourceProps } from 'aws-cdk-lib/aws-lambda-event-sources'
|
|
4
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
5
|
import { TagProps } from '../../types'
|
|
3
|
-
import { EdgeFunctionProps } from 'aws-cdk-lib/aws-cloudfront/lib/experimental'
|
|
4
6
|
import { QueueProps } from '../simple-queue-service'
|
|
5
|
-
import { SqsEventSourceProps } from 'aws-cdk-lib/aws-lambda-event-sources'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*/
|
|
@@ -22,6 +23,7 @@ export interface LambdaProps extends FunctionProps {
|
|
|
22
23
|
redriveq?: QueueProps
|
|
23
24
|
tags?: TagProps[]
|
|
24
25
|
timeoutInSecs?: number
|
|
26
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -36,6 +38,7 @@ export interface LambdaAliasProps extends AliasProps {
|
|
|
36
38
|
export interface LambdaEdgeProps extends EdgeFunctionProps {
|
|
37
39
|
tags?: TagProps[]
|
|
38
40
|
timeoutInSecs?: number
|
|
41
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetSecretValueCommand, SecretsManagerClient } from '@aws-sdk/client-secrets-manager'
|
|
2
2
|
import { Fn } from 'aws-cdk-lib'
|
|
3
|
-
import { Secret
|
|
3
|
+
import { Secret } from 'aws-cdk-lib/aws-secretsmanager'
|
|
4
4
|
import { CommonConstruct } from '../../common'
|
|
5
5
|
import { createCfnOutput, determineCredentials } from '../../utils'
|
|
6
|
+
import { SecretBaseProps } from './types'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @classdesc Provides operations on AWS Secrets Manager.
|
|
@@ -27,10 +28,13 @@ export class SecretsManager {
|
|
|
27
28
|
* @param scope scope in which this resource is defined
|
|
28
29
|
* @param props the secret properties
|
|
29
30
|
*/
|
|
30
|
-
public createSecret(id: string, scope: CommonConstruct, props:
|
|
31
|
+
public createSecret(id: string, scope: CommonConstruct, props: SecretBaseProps) {
|
|
32
|
+
if (!props) throw `Secret props undefined for ${id}`
|
|
33
|
+
if (!props.secretName) throw `Secret name undefined for ${id}`
|
|
34
|
+
|
|
31
35
|
const secret = new Secret(scope, `${id}`, {
|
|
32
36
|
...props,
|
|
33
|
-
secretName:
|
|
37
|
+
secretName: scope.resourceNameFormatter(props.secretName, props.resourceNameOptions),
|
|
34
38
|
})
|
|
35
39
|
|
|
36
40
|
createCfnOutput(`${id}-secretName`, scope, secret.secretName)
|
|
@@ -37,11 +37,12 @@ export class SnsManager {
|
|
|
37
37
|
emails: string[]
|
|
38
38
|
) {
|
|
39
39
|
if (!props) throw `Subscription props undefined for ${id}`
|
|
40
|
+
if (!props.topicName) throw `Subscription topicName undefined for ${id}`
|
|
40
41
|
|
|
41
42
|
const topic = new Topic(scope, id, {
|
|
42
43
|
...props,
|
|
43
|
-
displayName:
|
|
44
|
-
topicName:
|
|
44
|
+
displayName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
|
|
45
|
+
topicName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
|
|
45
46
|
})
|
|
46
47
|
|
|
47
48
|
if (emails && !_.isEmpty(emails)) {
|
|
@@ -68,11 +69,12 @@ export class SnsManager {
|
|
|
68
69
|
lambdaFunction: IFunction
|
|
69
70
|
) {
|
|
70
71
|
if (!props) throw `Subscription props undefined for ${id}`
|
|
72
|
+
if (!props.topicName) throw `Subscription topicName undefined for ${id}`
|
|
71
73
|
|
|
72
74
|
const topic = new Topic(scope, id, {
|
|
73
75
|
...props,
|
|
74
|
-
displayName:
|
|
75
|
-
topicName:
|
|
76
|
+
displayName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
|
|
77
|
+
topicName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
|
|
76
78
|
})
|
|
77
79
|
|
|
78
80
|
topic.addSubscription(new LambdaSubscription(lambdaFunction))
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { TopicProps } from 'aws-cdk-lib/aws-sns'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
|
-
export interface SubscriptionProps extends TopicProps {
|
|
6
|
+
export interface SubscriptionProps extends TopicProps {
|
|
7
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
8
|
+
}
|
|
@@ -32,6 +32,10 @@ export class SqsManager {
|
|
|
32
32
|
*/
|
|
33
33
|
public createQueue(id: string, scope: CommonConstruct, props: QueueProps, deadLetterQueue?: IQueue) {
|
|
34
34
|
if (!props) throw `Queue props undefined for ${id}`
|
|
35
|
+
if (!props.queueName) throw `Queue queueName undefined for ${id}`
|
|
36
|
+
|
|
37
|
+
let queueName = scope.resourceNameFormatter(props.queueName, props.resourceNameOptions)
|
|
38
|
+
if (props.fifo) queueName += '.fifo'
|
|
35
39
|
|
|
36
40
|
const queue = new Queue(scope, id, {
|
|
37
41
|
...props,
|
|
@@ -43,6 +47,7 @@ export class SqsManager {
|
|
|
43
47
|
queue: deadLetterQueue,
|
|
44
48
|
},
|
|
45
49
|
deliveryDelay: props.deliveryDelayInSecs ? Duration.seconds(props.deliveryDelayInSecs) : undefined,
|
|
50
|
+
queueName,
|
|
46
51
|
receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
|
|
47
52
|
? Duration.seconds(props.receiveMessageWaitTimeInSecs)
|
|
48
53
|
: props.receiveMessageWaitTime,
|
|
@@ -75,9 +80,7 @@ export class SqsManager {
|
|
|
75
80
|
public createRedriveQueueForLambda(id: string, scope: CommonConstruct, props: LambdaProps) {
|
|
76
81
|
return this.createQueue(`${id}`, scope, {
|
|
77
82
|
...props.redriveq,
|
|
78
|
-
queueName: props.redriveq
|
|
79
|
-
? `${props.functionName}-redriveq-${scope.props.stage}.fifo`
|
|
80
|
-
: `${props.functionName}-redriveq-${scope.props.stage}`,
|
|
83
|
+
queueName: `${props.functionName}-redriveq`,
|
|
81
84
|
})
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -98,13 +101,11 @@ export class SqsManager {
|
|
|
98
101
|
if (props.dlq) {
|
|
99
102
|
queueProps = {
|
|
100
103
|
...props.dlq,
|
|
101
|
-
queueName: props.dlq
|
|
102
|
-
? `${props.functionName}-dlq-${scope.props.stage}.fifo`
|
|
103
|
-
: `${props.functionName}-dlq-${scope.props.stage}`,
|
|
104
|
+
queueName: `${props.functionName}-dlq`,
|
|
104
105
|
}
|
|
105
106
|
} else {
|
|
106
107
|
queueProps = {
|
|
107
|
-
queueName: `${props.functionName}-dlq
|
|
108
|
+
queueName: `${props.functionName}-dlq`,
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as sqs from 'aws-cdk-lib/aws-sqs'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
3
|
import { TagProps } from '../../types'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -13,4 +14,5 @@ export interface QueueProps extends sqs.QueueProps {
|
|
|
13
14
|
retryBatchSize?: number
|
|
14
15
|
tags?: TagProps[]
|
|
15
16
|
visibilityTimeoutInSecs?: number
|
|
17
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
16
18
|
}
|
|
@@ -71,10 +71,14 @@ export class S3Manager {
|
|
|
71
71
|
* @param scope scope in which this resource is defined
|
|
72
72
|
* @param bucketName the bucket name
|
|
73
73
|
*/
|
|
74
|
-
public static determineBucketName(scope: CommonConstruct, bucketName: string) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
public static determineBucketName(scope: CommonConstruct, props: S3BucketProps, bucketName: string) {
|
|
75
|
+
if (!scope.props.excludeDomainNameForBuckets) {
|
|
76
|
+
return S3Manager.determineBucketNameByDomainName(scope, bucketName)
|
|
77
|
+
}
|
|
78
|
+
if (!scope.props.excludeAccountNumberForBuckets) {
|
|
79
|
+
return S3Manager.determineBucketNameByAccountAndRegion(scope, bucketName)
|
|
80
|
+
}
|
|
81
|
+
return scope.resourceNameFormatter(bucketName, props.resourceNameOptions)
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
/**
|
|
@@ -88,15 +92,15 @@ export class S3Manager {
|
|
|
88
92
|
|
|
89
93
|
let bucket: IBucket
|
|
90
94
|
|
|
91
|
-
const bucketName = S3Manager.determineBucketName(scope, props.bucketName)
|
|
95
|
+
const bucketName = S3Manager.determineBucketName(scope, props, props.bucketName)
|
|
92
96
|
|
|
93
97
|
if (props.existingBucket && props.bucketName) {
|
|
94
|
-
bucket = Bucket.fromBucketName(scope, `${id}`, bucketName)
|
|
98
|
+
bucket = Bucket.fromBucketName(scope, `${id}`, S3Manager.determineBucketName(scope, props, props.bucketName))
|
|
95
99
|
} else {
|
|
96
100
|
let logBucket
|
|
97
101
|
if (props.logBucketName) {
|
|
98
|
-
const logBucketName = S3Manager.determineBucketName(scope, props.logBucketName)
|
|
99
|
-
logBucket = Bucket.fromBucketName(scope, `${id}-logs`, logBucketName)
|
|
102
|
+
const logBucketName = S3Manager.determineBucketName(scope, props, props.logBucketName)
|
|
103
|
+
logBucket = Bucket.fromBucketName(scope, `${id}-logs`, props.logBucketName)
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
bucket = new Bucket(scope, `${id}-bucket`, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { TagProps } from '../../types'
|
|
2
1
|
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
3
2
|
import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment'
|
|
3
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
4
|
+
import { TagProps } from '../../types'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*/
|
|
@@ -24,5 +25,6 @@ export interface S3BucketProps extends s3.BucketProps {
|
|
|
24
25
|
existingBucket?: boolean
|
|
25
26
|
lifecycleRules?: LifecycleRule[]
|
|
26
27
|
logBucketName?: string
|
|
28
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
27
29
|
tags?: TagProps[]
|
|
28
30
|
}
|
|
@@ -474,6 +474,8 @@ export class SfnManager {
|
|
|
474
474
|
role?: IRole
|
|
475
475
|
) {
|
|
476
476
|
if (!props) throw `State Machine props undefined for ${id}`
|
|
477
|
+
if (!props.stateMachineName) throw `State Machine stateMachineName undefined for ${id}`
|
|
478
|
+
|
|
477
479
|
const stateMachine = new StateMachine(scope, `${id}`, {
|
|
478
480
|
...props,
|
|
479
481
|
definitionBody: DefinitionBody.fromChainable(definition),
|
|
@@ -483,7 +485,7 @@ export class SfnManager {
|
|
|
483
485
|
level: props.logs?.level ?? LogLevel.ALL,
|
|
484
486
|
},
|
|
485
487
|
role,
|
|
486
|
-
stateMachineName:
|
|
488
|
+
stateMachineName: scope.resourceNameFormatter(props.stateMachineName, props.resourceNameOptions),
|
|
487
489
|
})
|
|
488
490
|
|
|
489
491
|
createCfnOutput(`${id}-stateMachineName`, scope, stateMachine.stateMachineName)
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
SqsSendMessageProps,
|
|
19
19
|
StepFunctionsStartExecutionProps,
|
|
20
20
|
} from 'aws-cdk-lib/aws-stepfunctions-tasks'
|
|
21
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
*/
|
|
@@ -107,7 +108,9 @@ export interface SfnCallApiGatewayRestApiEndpointProps extends CallApiGatewayRes
|
|
|
107
108
|
|
|
108
109
|
/**
|
|
109
110
|
*/
|
|
110
|
-
export interface SfnStateMachineProps extends StateMachineProps {
|
|
111
|
+
export interface SfnStateMachineProps extends StateMachineProps {
|
|
112
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
113
|
+
}
|
|
111
114
|
|
|
112
115
|
/**
|
|
113
116
|
*/
|
|
@@ -35,15 +35,18 @@ export class VpcManager {
|
|
|
35
35
|
*/
|
|
36
36
|
public createVpc(id: string, scope: CommonConstruct, props: VpcProps) {
|
|
37
37
|
if (!props) throw `Vpc props undefined for ${id}`
|
|
38
|
+
if (!props.vpcName) throw `Vpc vpcName undefined for ${id}`
|
|
38
39
|
|
|
40
|
+
const vpcName = scope.resourceNameFormatter(props.vpcName, props.resourceNameOptions)
|
|
39
41
|
let vpc
|
|
40
42
|
if (props.isIPV6) {
|
|
41
43
|
vpc = new Ipv6Vpc(scope, `${id}`, {
|
|
42
44
|
...props,
|
|
43
45
|
subnetConfiguration: [
|
|
44
|
-
{ name: `${
|
|
45
|
-
{ name: `${
|
|
46
|
+
{ name: `${vpcName}-public`, subnetType: SubnetType.PUBLIC },
|
|
47
|
+
{ name: `${vpcName}-private`, subnetType: SubnetType.PRIVATE_WITH_EGRESS },
|
|
46
48
|
],
|
|
49
|
+
vpcName,
|
|
47
50
|
})
|
|
48
51
|
} else {
|
|
49
52
|
vpc = new Vpc(scope, `${id}`, props)
|
|
@@ -88,6 +91,9 @@ export class VpcManager {
|
|
|
88
91
|
* @param vpcIdentifier optional identifier for VPC
|
|
89
92
|
*/
|
|
90
93
|
public retrieveCommonVpc(id: string, scope: CommonConstruct, vpcIdentifier?: string) {
|
|
91
|
-
|
|
94
|
+
const vpcName = scope.resourceNameFormatter(vpcIdentifier ?? CommonVpcIdentifier)
|
|
95
|
+
return Vpc.fromLookup(scope, `${id}`, {
|
|
96
|
+
vpcName: scope.resourceNameFormatter(vpcIdentifier ?? CommonVpcIdentifier),
|
|
97
|
+
})
|
|
92
98
|
}
|
|
93
99
|
}
|
|
@@ -28,11 +28,12 @@ export class WafManager {
|
|
|
28
28
|
*/
|
|
29
29
|
public createIpSet(id: string, scope: CommonConstruct, props: WafIPSetProps) {
|
|
30
30
|
if (!props) throw `WAF Ip Set props undefined for ${id}`
|
|
31
|
+
if (!props.name) throw `WAF Ip Set name undefined for ${id}`
|
|
31
32
|
|
|
32
33
|
const ipSet = new CfnIPSet(scope, `${id}`, {
|
|
33
34
|
...props,
|
|
34
35
|
description: `IP Set for ${id} - ${scope.props.stage} stage`,
|
|
35
|
-
name: scope.
|
|
36
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
36
37
|
})
|
|
37
38
|
|
|
38
39
|
createCfnOutput(`${id}-ipSetId`, scope, ipSet.attrId)
|
|
@@ -49,11 +50,12 @@ export class WafManager {
|
|
|
49
50
|
*/
|
|
50
51
|
public createWebAcl(id: string, scope: CommonConstruct, props: WafWebACLProps) {
|
|
51
52
|
if (!props) throw `WAF WebACL props undefined for ${id}`
|
|
53
|
+
if (!props.name) throw `WAF WebACL name undefined for ${id}`
|
|
52
54
|
|
|
53
55
|
const webAcl = new CfnWebACL(scope, `${id}`, {
|
|
54
56
|
...props,
|
|
55
57
|
description: `Web Acl for ${id} - ${scope.props.stage} stage`,
|
|
56
|
-
name: scope.
|
|
58
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
57
59
|
tags: [{ key: 'service', value: scope.props.name }],
|
|
58
60
|
})
|
|
59
61
|
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { CfnIPSetProps, CfnWebACLProps } from 'aws-cdk-lib/aws-wafv2'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
|
-
export interface WafIPSetProps extends CfnIPSetProps {
|
|
6
|
+
export interface WafIPSetProps extends CfnIPSetProps {
|
|
7
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
8
|
+
}
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
*/
|
|
9
|
-
export interface WafWebACLProps extends CfnWebACLProps {
|
|
12
|
+
export interface WafWebACLProps extends CfnWebACLProps {
|
|
13
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
14
|
+
}
|