@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
|
@@ -35,6 +35,11 @@ class SqsManager {
|
|
|
35
35
|
createQueue(id, scope, props, deadLetterQueue) {
|
|
36
36
|
if (!props)
|
|
37
37
|
throw `Queue props undefined for ${id}`;
|
|
38
|
+
if (!props.queueName)
|
|
39
|
+
throw `Queue queueName undefined for ${id}`;
|
|
40
|
+
let queueName = scope.resourceNameFormatter(props.queueName, props.resourceNameOptions);
|
|
41
|
+
if (props.fifo)
|
|
42
|
+
queueName += '.fifo';
|
|
38
43
|
const queue = new aws_sqs_1.Queue(scope, id, {
|
|
39
44
|
...props,
|
|
40
45
|
dataKeyReuse: props.dataKeyReuseInSecs ? aws_cdk_lib_1.Duration.seconds(props.dataKeyReuseInSecs) : props.dataKeyReuse,
|
|
@@ -45,6 +50,7 @@ class SqsManager {
|
|
|
45
50
|
queue: deadLetterQueue,
|
|
46
51
|
},
|
|
47
52
|
deliveryDelay: props.deliveryDelayInSecs ? aws_cdk_lib_1.Duration.seconds(props.deliveryDelayInSecs) : undefined,
|
|
53
|
+
queueName,
|
|
48
54
|
receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
|
|
49
55
|
? aws_cdk_lib_1.Duration.seconds(props.receiveMessageWaitTimeInSecs)
|
|
50
56
|
: props.receiveMessageWaitTime,
|
|
@@ -73,9 +79,7 @@ class SqsManager {
|
|
|
73
79
|
createRedriveQueueForLambda(id, scope, props) {
|
|
74
80
|
return this.createQueue(`${id}`, scope, {
|
|
75
81
|
...props.redriveq,
|
|
76
|
-
queueName: props.redriveq
|
|
77
|
-
? `${props.functionName}-redriveq-${scope.props.stage}.fifo`
|
|
78
|
-
: `${props.functionName}-redriveq-${scope.props.stage}`,
|
|
82
|
+
queueName: `${props.functionName}-redriveq`,
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
85
|
/**
|
|
@@ -90,14 +94,12 @@ class SqsManager {
|
|
|
90
94
|
if (props.dlq) {
|
|
91
95
|
queueProps = {
|
|
92
96
|
...props.dlq,
|
|
93
|
-
queueName: props.dlq
|
|
94
|
-
? `${props.functionName}-dlq-${scope.props.stage}.fifo`
|
|
95
|
-
: `${props.functionName}-dlq-${scope.props.stage}`,
|
|
97
|
+
queueName: `${props.functionName}-dlq`,
|
|
96
98
|
};
|
|
97
99
|
}
|
|
98
100
|
else {
|
|
99
101
|
queueProps = {
|
|
100
|
-
queueName: `${props.functionName}-dlq
|
|
102
|
+
queueName: `${props.functionName}-dlq`,
|
|
101
103
|
};
|
|
102
104
|
}
|
|
103
105
|
return this.createQueue(`${id}`, scope, queueProps, deadLetterQueue);
|
|
@@ -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
|
*/
|
|
@@ -12,4 +13,5 @@ export interface QueueProps extends sqs.QueueProps {
|
|
|
12
13
|
retryBatchSize?: number;
|
|
13
14
|
tags?: TagProps[];
|
|
14
15
|
visibilityTimeoutInSecs?: number;
|
|
16
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
15
17
|
}
|
|
@@ -42,7 +42,7 @@ export declare class S3Manager {
|
|
|
42
42
|
* @param scope scope in which this resource is defined
|
|
43
43
|
* @param bucketName the bucket name
|
|
44
44
|
*/
|
|
45
|
-
static determineBucketName(scope: CommonConstruct, bucketName: string): string;
|
|
45
|
+
static determineBucketName(scope: CommonConstruct, props: S3BucketProps, bucketName: string): string;
|
|
46
46
|
/**
|
|
47
47
|
* @summary Method to create a s3 bucket
|
|
48
48
|
* @param id scoped id of the resource
|
|
@@ -69,10 +69,14 @@ class S3Manager {
|
|
|
69
69
|
* @param scope scope in which this resource is defined
|
|
70
70
|
* @param bucketName the bucket name
|
|
71
71
|
*/
|
|
72
|
-
static determineBucketName(scope, bucketName) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
static determineBucketName(scope, props, bucketName) {
|
|
73
|
+
if (!scope.props.excludeDomainNameForBuckets) {
|
|
74
|
+
return S3Manager.determineBucketNameByDomainName(scope, bucketName);
|
|
75
|
+
}
|
|
76
|
+
if (!scope.props.excludeAccountNumberForBuckets) {
|
|
77
|
+
return S3Manager.determineBucketNameByAccountAndRegion(scope, bucketName);
|
|
78
|
+
}
|
|
79
|
+
return scope.resourceNameFormatter(bucketName, props.resourceNameOptions);
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
78
82
|
* @summary Method to create a s3 bucket
|
|
@@ -84,15 +88,15 @@ class S3Manager {
|
|
|
84
88
|
if (!props)
|
|
85
89
|
throw `S3 props undefined for ${id}`;
|
|
86
90
|
let bucket;
|
|
87
|
-
const bucketName = S3Manager.determineBucketName(scope, props.bucketName);
|
|
91
|
+
const bucketName = S3Manager.determineBucketName(scope, props, props.bucketName);
|
|
88
92
|
if (props.existingBucket && props.bucketName) {
|
|
89
|
-
bucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}`, bucketName);
|
|
93
|
+
bucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}`, S3Manager.determineBucketName(scope, props, props.bucketName));
|
|
90
94
|
}
|
|
91
95
|
else {
|
|
92
96
|
let logBucket;
|
|
93
97
|
if (props.logBucketName) {
|
|
94
|
-
const logBucketName = S3Manager.determineBucketName(scope, props.logBucketName);
|
|
95
|
-
logBucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}-logs`, logBucketName);
|
|
98
|
+
const logBucketName = S3Manager.determineBucketName(scope, props, props.logBucketName);
|
|
99
|
+
logBucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}-logs`, props.logBucketName);
|
|
96
100
|
}
|
|
97
101
|
bucket = new aws_s3_1.Bucket(scope, `${id}-bucket`, {
|
|
98
102
|
...props,
|
|
@@ -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
|
export interface LifecycleRule extends s3.LifecycleRule {
|
|
@@ -21,5 +22,6 @@ export interface S3BucketProps extends s3.BucketProps {
|
|
|
21
22
|
existingBucket?: boolean;
|
|
22
23
|
lifecycleRules?: LifecycleRule[];
|
|
23
24
|
logBucketName?: string;
|
|
25
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
24
26
|
tags?: TagProps[];
|
|
25
27
|
}
|
|
@@ -366,6 +366,8 @@ class SfnManager {
|
|
|
366
366
|
createStateMachine(id, scope, props, definition, logGroup, role) {
|
|
367
367
|
if (!props)
|
|
368
368
|
throw `State Machine props undefined for ${id}`;
|
|
369
|
+
if (!props.stateMachineName)
|
|
370
|
+
throw `State Machine stateMachineName undefined for ${id}`;
|
|
369
371
|
const stateMachine = new aws_stepfunctions_1.StateMachine(scope, `${id}`, {
|
|
370
372
|
...props,
|
|
371
373
|
definitionBody: aws_stepfunctions_1.DefinitionBody.fromChainable(definition),
|
|
@@ -375,7 +377,7 @@ class SfnManager {
|
|
|
375
377
|
level: props.logs?.level ?? aws_stepfunctions_1.LogLevel.ALL,
|
|
376
378
|
},
|
|
377
379
|
role,
|
|
378
|
-
stateMachineName:
|
|
380
|
+
stateMachineName: scope.resourceNameFormatter(props.stateMachineName, props.resourceNameOptions),
|
|
379
381
|
});
|
|
380
382
|
(0, utils_1.createCfnOutput)(`${id}-stateMachineName`, scope, stateMachine.stateMachineName);
|
|
381
383
|
(0, utils_1.createCfnOutput)(`${id}-stateMachineArn`, scope, stateMachine.stateMachineArn);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChoiceProps, FailProps, MapProps, ParallelProps, PassProps, RetryProps, StateMachineProps, SucceedProps, WaitProps } from 'aws-cdk-lib/aws-stepfunctions';
|
|
2
2
|
import { CallApiGatewayRestApiEndpointProps, DynamoDeleteItemProps, DynamoGetItemProps, DynamoPutItemProps, LambdaInvokeProps, SqsSendMessageProps, StepFunctionsStartExecutionProps } from 'aws-cdk-lib/aws-stepfunctions-tasks';
|
|
3
|
+
import { ResourceNameFormatterProps } from '../../common';
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
6
|
export interface SfnSucceedProps extends SucceedProps {
|
|
@@ -76,6 +77,7 @@ export interface SfnCallApiGatewayRestApiEndpointProps extends CallApiGatewayRes
|
|
|
76
77
|
/**
|
|
77
78
|
*/
|
|
78
79
|
export interface SfnStateMachineProps extends StateMachineProps {
|
|
80
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
79
81
|
}
|
|
80
82
|
/**
|
|
81
83
|
*/
|
|
@@ -38,14 +38,18 @@ class VpcManager {
|
|
|
38
38
|
createVpc(id, scope, props) {
|
|
39
39
|
if (!props)
|
|
40
40
|
throw `Vpc props undefined for ${id}`;
|
|
41
|
+
if (!props.vpcName)
|
|
42
|
+
throw `Vpc vpcName undefined for ${id}`;
|
|
43
|
+
const vpcName = scope.resourceNameFormatter(props.vpcName, props.resourceNameOptions);
|
|
41
44
|
let vpc;
|
|
42
45
|
if (props.isIPV6) {
|
|
43
46
|
vpc = new ipv6_1.Ipv6Vpc(scope, `${id}`, {
|
|
44
47
|
...props,
|
|
45
48
|
subnetConfiguration: [
|
|
46
|
-
{ name: `${
|
|
47
|
-
{ name: `${
|
|
49
|
+
{ name: `${vpcName}-public`, subnetType: aws_ec2_1.SubnetType.PUBLIC },
|
|
50
|
+
{ name: `${vpcName}-private`, subnetType: aws_ec2_1.SubnetType.PRIVATE_WITH_EGRESS },
|
|
48
51
|
],
|
|
52
|
+
vpcName,
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
55
|
else {
|
|
@@ -78,7 +82,10 @@ class VpcManager {
|
|
|
78
82
|
* @param vpcIdentifier optional identifier for VPC
|
|
79
83
|
*/
|
|
80
84
|
retrieveCommonVpc(id, scope, vpcIdentifier) {
|
|
81
|
-
|
|
85
|
+
const vpcName = scope.resourceNameFormatter(vpcIdentifier ?? CommonVpcIdentifier);
|
|
86
|
+
return aws_ec2_1.Vpc.fromLookup(scope, `${id}`, {
|
|
87
|
+
vpcName: scope.resourceNameFormatter(vpcIdentifier ?? CommonVpcIdentifier),
|
|
88
|
+
});
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
exports.VpcManager = VpcManager;
|
|
@@ -29,10 +29,12 @@ class WafManager {
|
|
|
29
29
|
createIpSet(id, scope, props) {
|
|
30
30
|
if (!props)
|
|
31
31
|
throw `WAF Ip Set props undefined for ${id}`;
|
|
32
|
+
if (!props.name)
|
|
33
|
+
throw `WAF Ip Set name undefined for ${id}`;
|
|
32
34
|
const ipSet = new aws_wafv2_1.CfnIPSet(scope, `${id}`, {
|
|
33
35
|
...props,
|
|
34
36
|
description: `IP Set for ${id} - ${scope.props.stage} stage`,
|
|
35
|
-
name: scope.
|
|
37
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
36
38
|
});
|
|
37
39
|
(0, utils_1.createCfnOutput)(`${id}-ipSetId`, scope, ipSet.attrId);
|
|
38
40
|
(0, utils_1.createCfnOutput)(`${id}-ipSetArn`, scope, ipSet.attrArn);
|
|
@@ -47,10 +49,12 @@ class WafManager {
|
|
|
47
49
|
createWebAcl(id, scope, props) {
|
|
48
50
|
if (!props)
|
|
49
51
|
throw `WAF WebACL props undefined for ${id}`;
|
|
52
|
+
if (!props.name)
|
|
53
|
+
throw `WAF WebACL name undefined for ${id}`;
|
|
50
54
|
const webAcl = new aws_wafv2_1.CfnWebACL(scope, `${id}`, {
|
|
51
55
|
...props,
|
|
52
56
|
description: `Web Acl for ${id} - ${scope.props.stage} stage`,
|
|
53
|
-
name: scope.
|
|
57
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
54
58
|
tags: [{ key: 'service', value: scope.props.name }],
|
|
55
59
|
});
|
|
56
60
|
(0, utils_1.createCfnOutput)(`${id}-webAclId`, scope, webAcl.attrId);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { CfnIPSetProps, CfnWebACLProps } from 'aws-cdk-lib/aws-wafv2';
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common';
|
|
2
3
|
/**
|
|
3
4
|
*/
|
|
4
5
|
export interface WafIPSetProps extends CfnIPSetProps {
|
|
6
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
*/
|
|
8
10
|
export interface WafWebACLProps extends CfnWebACLProps {
|
|
11
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
9
12
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.10.1",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=16 <=20",
|
|
8
|
-
"pnpm": "=
|
|
8
|
+
"pnpm": "=9"
|
|
9
9
|
},
|
|
10
10
|
"packageManager": "pnpm@8.15.8",
|
|
11
11
|
"repository": {
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
WafManager,
|
|
34
34
|
} from '../services'
|
|
35
35
|
import { createCfnOutput } from '../utils'
|
|
36
|
-
import { CommonStackProps } from './types'
|
|
36
|
+
import { CommonStackProps, ResourceNameFormatterProps } from './types'
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @subcategory Construct
|
|
@@ -118,6 +118,21 @@ export class CommonConstruct extends Construct {
|
|
|
118
118
|
this.determineFullyQualifiedDomain()
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @summary Helper method to format a resource name based on the provided options
|
|
123
|
+
* @param resourceName the resource name to format
|
|
124
|
+
* @param options options to control the formatting of the resource name
|
|
125
|
+
* @returns The formatted resource name
|
|
126
|
+
*/
|
|
127
|
+
public resourceNameFormatter(resourceName: string, options?: ResourceNameFormatterProps) {
|
|
128
|
+
const resourceNameElements = []
|
|
129
|
+
resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
|
|
130
|
+
resourceNameElements.push(resourceName)
|
|
131
|
+
resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
|
|
132
|
+
resourceNameElements.push(this.props.stage)
|
|
133
|
+
return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-')
|
|
134
|
+
}
|
|
135
|
+
|
|
121
136
|
/**
|
|
122
137
|
* @summary Helper method to add CloudFormation outputs from the construct
|
|
123
138
|
* @param id scoped id of the resource
|
|
@@ -52,11 +52,14 @@ export class CommonStack extends Stack {
|
|
|
52
52
|
return {
|
|
53
53
|
domainName: this.node.tryGetContext('domainName'),
|
|
54
54
|
excludeDomainNameForBuckets: this.node.tryGetContext('excludeDomainNameForBuckets'),
|
|
55
|
+
excludeAccountNumberForBuckets: this.node.tryGetContext('excludeAccountNumberForBuckets'),
|
|
55
56
|
extraContexts: this.node.tryGetContext('extraContexts'),
|
|
56
57
|
logRetention: this.node.tryGetContext('logRetention'),
|
|
57
58
|
name: props.stackName || 'cdk-utils',
|
|
58
59
|
nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
|
|
59
60
|
region: this.node.tryGetContext('region'),
|
|
61
|
+
resourcePrefix: this.node.tryGetContext('resourcePrefix'),
|
|
62
|
+
resourceSuffix: this.node.tryGetContext('resourceSuffix'),
|
|
60
63
|
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
61
64
|
stackName: props.stackName,
|
|
62
65
|
stage: this.node.tryGetContext('stage'),
|
|
@@ -7,9 +7,18 @@ import { BaseProps } from '../../common'
|
|
|
7
7
|
*/
|
|
8
8
|
export interface CommonStackProps extends BaseProps, StackProps {
|
|
9
9
|
region: string
|
|
10
|
+
resourceProjectIdentifier?: string
|
|
11
|
+
resourcePrefix?: string
|
|
12
|
+
resourceSuffix?: string
|
|
10
13
|
logRetention?: RetentionDays
|
|
11
14
|
defaultReservedLambdaConcurrentExecutions?: number
|
|
12
15
|
defaultTracing?: Tracing
|
|
13
16
|
excludeDomainNameForBuckets?: boolean
|
|
17
|
+
excludeAccountNumberForBuckets?: boolean
|
|
14
18
|
nodejsRuntime?: Runtime
|
|
15
19
|
}
|
|
20
|
+
|
|
21
|
+
export interface ResourceNameFormatterProps {
|
|
22
|
+
prefix?: string
|
|
23
|
+
suffix?: string
|
|
24
|
+
}
|
|
@@ -126,6 +126,8 @@ export class ApiToAnyTarget extends CommonConstruct {
|
|
|
126
126
|
return
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
if (!this.props.api.restApi?.restApiName) throw `RestApi name undefined for ${this.id}`
|
|
130
|
+
|
|
129
131
|
this.apiToAnyTargetRestApi.api = new RestApi(this, `${this.id}-rest-api`, {
|
|
130
132
|
cloudWatchRole: this.props.api.restApi?.cloudWatchRole ?? true,
|
|
131
133
|
defaultCorsPreflightOptions: {
|
|
@@ -151,8 +153,11 @@ export class ApiToAnyTarget extends CommonConstruct {
|
|
|
151
153
|
endpointConfiguration: {
|
|
152
154
|
types: [this.isProductionStage() ? EndpointType.EDGE : EndpointType.REGIONAL],
|
|
153
155
|
},
|
|
154
|
-
restApiName: `${this.id}-rest-api-${this.props.stage}`,
|
|
155
156
|
...this.props.api.restApi,
|
|
157
|
+
restApiName: this.resourceNameFormatter(
|
|
158
|
+
this.props.api.restApi?.restApiName,
|
|
159
|
+
this.props.api.restApi?.resourceNameOptions
|
|
160
|
+
),
|
|
156
161
|
})
|
|
157
162
|
this.addCfnOutput(`${this.id}-restApiId`, this.apiToAnyTargetRestApi.api.restApiId)
|
|
158
163
|
this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToAnyTargetRestApi.api.root.resourceId)
|
|
@@ -9,13 +9,12 @@ import {
|
|
|
9
9
|
MethodResponse,
|
|
10
10
|
MockIntegration,
|
|
11
11
|
Resource,
|
|
12
|
-
RestApiProps,
|
|
13
12
|
} from 'aws-cdk-lib/aws-apigateway'
|
|
14
13
|
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager'
|
|
15
14
|
import { LogGroup } from 'aws-cdk-lib/aws-logs'
|
|
16
15
|
import { IHostedZone } from 'aws-cdk-lib/aws-route53'
|
|
17
16
|
import { CommonStackProps } from '../../common'
|
|
18
|
-
import { AcmProps } from '../../services'
|
|
17
|
+
import { AcmProps, RestApigProps } from '../../services'
|
|
19
18
|
|
|
20
19
|
export interface ApiToAnyTargetRestApiType {
|
|
21
20
|
accessLogGroup: LogGroup
|
|
@@ -54,7 +53,7 @@ export interface ApiToAnyTargetRestApiProps {
|
|
|
54
53
|
importedRestApiRootResourceRef?: string
|
|
55
54
|
methodErrorResponse: MethodResponse
|
|
56
55
|
methodResponse: MethodResponse
|
|
57
|
-
restApi:
|
|
56
|
+
restApi: RestApigProps
|
|
58
57
|
useExisting: boolean
|
|
59
58
|
withResource?: boolean
|
|
60
59
|
}
|
|
@@ -159,12 +159,12 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
159
159
|
this.apiEvent.eventBus = EventBus.fromEventBusName(
|
|
160
160
|
this,
|
|
161
161
|
`${this.id}-event-bus`,
|
|
162
|
-
|
|
162
|
+
this.resourceNameFormatter(this.props.event.eventBusName ?? 'default')
|
|
163
163
|
)
|
|
164
164
|
return
|
|
165
165
|
}
|
|
166
166
|
this.apiEvent.eventBus = this.eventManager.createEventBus(`${this.id}-event-bus`, this, {
|
|
167
|
-
eventBusName:
|
|
167
|
+
eventBusName: this.props.event.eventBusName ?? 'default',
|
|
168
168
|
})
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -175,7 +175,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
175
175
|
if (this.props.api.useExisting) return
|
|
176
176
|
this.apiEvent.logGroup = this.logManager.createLogGroup(`${this.id}-log`, this, {
|
|
177
177
|
...{
|
|
178
|
-
logGroupName: `/${this.id}/events/api-to-eventbridge-target`,
|
|
178
|
+
logGroupName: `/${this.resourceNameFormatter(this.id)}/events/api-to-eventbridge-target`,
|
|
179
179
|
},
|
|
180
180
|
...this.props.event.logGroup,
|
|
181
181
|
})
|
|
@@ -186,11 +186,12 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
186
186
|
*/
|
|
187
187
|
protected createApiToEventBridgeTargetRule() {
|
|
188
188
|
if (this.props.api.useExisting) return
|
|
189
|
+
if (!this.props.event.rule.ruleName) throw `Event ruleName undefined for ${this.id}`
|
|
190
|
+
|
|
189
191
|
this.props.event.rule = {
|
|
190
192
|
eventPattern: {
|
|
191
193
|
source: ['api-to-eventbridge-target'],
|
|
192
194
|
},
|
|
193
|
-
ruleName: `${this.id}-api-to-eventbridge-target`,
|
|
194
195
|
...this.props.event.rule,
|
|
195
196
|
}
|
|
196
197
|
this.apiEvent.rule = this.eventManager.createRule(
|
|
@@ -355,7 +356,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
355
356
|
`${this.id}-rest-api-access-log`,
|
|
356
357
|
this,
|
|
357
358
|
{
|
|
358
|
-
logGroupName: `/custom/api/${this.id}-rest-api-access`,
|
|
359
|
+
logGroupName: `/custom/api/${this.resourceNameFormatter(this.id)}-rest-api-access`,
|
|
359
360
|
removalPolicy: RemovalPolicy.DESTROY,
|
|
360
361
|
}
|
|
361
362
|
)
|
|
@@ -374,6 +375,8 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
374
375
|
return
|
|
375
376
|
}
|
|
376
377
|
|
|
378
|
+
if (!this.props.api.restApi?.restApiName) throw `RestApi name undefined for ${this.id}`
|
|
379
|
+
|
|
377
380
|
this.apiToEventBridgeTargetRestApi.api = new RestApi(this, `${this.id}-rest-api`, {
|
|
378
381
|
cloudWatchRole: this.props.api.restApi?.cloudWatchRole ?? true,
|
|
379
382
|
defaultCorsPreflightOptions: {
|
|
@@ -402,9 +405,13 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
402
405
|
endpointConfiguration: {
|
|
403
406
|
types: [EndpointType.REGIONAL],
|
|
404
407
|
},
|
|
405
|
-
restApiName: `${this.id}-rest-api-${this.props.stage}`,
|
|
406
408
|
...this.props.api.restApi,
|
|
409
|
+
restApiName: this.resourceNameFormatter(
|
|
410
|
+
this.props.api.restApi?.restApiName,
|
|
411
|
+
this.props.api.restApi?.resourceNameOptions
|
|
412
|
+
),
|
|
407
413
|
})
|
|
414
|
+
|
|
408
415
|
this.addCfnOutput(`${this.id}-restApiId`, this.apiToEventBridgeTargetRestApi.api.restApiId)
|
|
409
416
|
this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToEventBridgeTargetRestApi.api.root.resourceId)
|
|
410
417
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { IEventBus, Rule } from 'aws-cdk-lib/aws-events'
|
|
2
|
-
import { LogGroup } from 'aws-cdk-lib/aws-logs'
|
|
3
1
|
import {
|
|
4
2
|
DomainName,
|
|
5
3
|
IAuthorizer,
|
|
@@ -12,15 +10,16 @@ import {
|
|
|
12
10
|
Model,
|
|
13
11
|
ModelOptions,
|
|
14
12
|
Resource,
|
|
15
|
-
RestApiProps,
|
|
16
13
|
} from 'aws-cdk-lib/aws-apigateway'
|
|
17
14
|
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager'
|
|
15
|
+
import { IEventBus, Rule } from 'aws-cdk-lib/aws-events'
|
|
16
|
+
import { PolicyDocument, Role } from 'aws-cdk-lib/aws-iam'
|
|
17
|
+
import { AssetCode } from 'aws-cdk-lib/aws-lambda'
|
|
18
|
+
import { LogGroup } from 'aws-cdk-lib/aws-logs'
|
|
18
19
|
import { IHostedZone } from 'aws-cdk-lib/aws-route53'
|
|
19
20
|
import { ITopic } from 'aws-cdk-lib/aws-sns'
|
|
20
|
-
import { PolicyDocument, Role } from 'aws-cdk-lib/aws-iam'
|
|
21
21
|
import { CommonStackProps } from '../../common'
|
|
22
|
-
import { AcmProps, EventRuleProps, LambdaProps, LogProps } from '../../services'
|
|
23
|
-
import { AssetCode } from 'aws-cdk-lib/aws-lambda'
|
|
22
|
+
import { AcmProps, EventRuleProps, LambdaProps, LogProps, RestApigProps } from '../../services'
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
*/
|
|
@@ -73,7 +72,7 @@ export interface ApiToEventBridgeTargetRestApiProps {
|
|
|
73
72
|
methodResponse?: MethodResponse
|
|
74
73
|
resource: string
|
|
75
74
|
responseModel?: ModelOptions
|
|
76
|
-
restApi?:
|
|
75
|
+
restApi?: RestApigProps
|
|
77
76
|
useExisting: boolean
|
|
78
77
|
withResource?: boolean
|
|
79
78
|
}
|
|
@@ -362,7 +362,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
|
|
|
362
362
|
`${this.id}-destined-topic`,
|
|
363
363
|
this,
|
|
364
364
|
{
|
|
365
|
-
topicName: `${this.id}-destined-topic
|
|
365
|
+
topicName: this.resourceNameFormatter(`${this.id}-destined-topic`),
|
|
366
366
|
},
|
|
367
367
|
this.apiDestinedLambda.function
|
|
368
368
|
)
|
|
@@ -513,6 +513,8 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
|
|
|
513
513
|
removalPolicy: RemovalPolicy.DESTROY,
|
|
514
514
|
})
|
|
515
515
|
|
|
516
|
+
if (!this.props.api.restApi?.restApiName) throw `RestApi name undefined for ${this.id}`
|
|
517
|
+
|
|
516
518
|
this.apiDestinedRestApi.api = new RestApi(this, `${this.id}-sns-rest-api`, {
|
|
517
519
|
defaultCorsPreflightOptions: {
|
|
518
520
|
allowHeaders: Cors.DEFAULT_HEADERS,
|
|
@@ -535,8 +537,11 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
|
|
|
535
537
|
endpointConfiguration: {
|
|
536
538
|
types: [EndpointType.REGIONAL],
|
|
537
539
|
},
|
|
538
|
-
restApiName: `${this.id}-destined-rest-api-${this.props.stage}`,
|
|
539
540
|
...this.props.api,
|
|
541
|
+
restApiName: this.resourceNameFormatter(
|
|
542
|
+
this.props.api.restApi?.restApiName,
|
|
543
|
+
this.props.api.restApi?.resourceNameOptions
|
|
544
|
+
),
|
|
540
545
|
})
|
|
541
546
|
this.addCfnOutput(`${this.id}-restApiId`, this.apiDestinedRestApi.api.restApiId)
|
|
542
547
|
this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiDestinedRestApi.api.root.resourceId)
|
|
@@ -138,7 +138,7 @@ export class ApiToLambdaTarget extends CommonConstruct {
|
|
|
138
138
|
this.apiToLambdaTargetRestApi.lambda = Function.fromFunctionName(
|
|
139
139
|
this,
|
|
140
140
|
`${this.id}-lambda`,
|
|
141
|
-
this.props.lambdaFunctionName
|
|
141
|
+
this.resourceNameFormatter(this.props.lambdaFunctionName)
|
|
142
142
|
)
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -156,7 +156,7 @@ export class ApiToLambdaTarget extends CommonConstruct {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
const accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
|
|
159
|
-
logGroupName: `/custom/api/${this.id}-rest-api-access`,
|
|
159
|
+
logGroupName: `/custom/api/${this.resourceNameFormatter(this.id)}-rest-api-access`,
|
|
160
160
|
removalPolicy: RemovalPolicy.DESTROY,
|
|
161
161
|
})
|
|
162
162
|
|
|
@@ -79,7 +79,7 @@ export class ApplicationConfiguration extends CommonConstruct {
|
|
|
79
79
|
this.appConfigDeploymentStrategy = new CfnDeploymentStrategy(this, `${this.id}-ac-deployment-strategy`, {
|
|
80
80
|
deploymentDurationInMinutes: this.props.appConfig.deploymentStrategy.deploymentDurationInMinutes,
|
|
81
81
|
growthFactor: this.props.appConfig.deploymentStrategy.growthFactor,
|
|
82
|
-
name: this.props.appConfig.deploymentStrategy.name,
|
|
82
|
+
name: this.resourceNameFormatter(this.props.appConfig.deploymentStrategy.name),
|
|
83
83
|
replicateTo: this.props.appConfig.deploymentStrategy.replicateTo,
|
|
84
84
|
})
|
|
85
85
|
}
|
|
@@ -187,11 +187,11 @@ export class LambdaWithIamAccess extends CommonConstruct {
|
|
|
187
187
|
*/
|
|
188
188
|
protected createIamUserForLambdaFunction() {
|
|
189
189
|
this.lambdaIamUser = new User(this, `${this.id}-lambda-user`, {
|
|
190
|
-
userName: `${this.id}-user
|
|
190
|
+
userName: this.resourceNameFormatter(`${this.id}-user`),
|
|
191
191
|
})
|
|
192
192
|
|
|
193
193
|
new Policy(this, `${this.id}-lambda-user-policy`, {
|
|
194
|
-
policyName: `${this.id}-policy
|
|
194
|
+
policyName: this.resourceNameFormatter(`${this.id}-policy`),
|
|
195
195
|
statements: [
|
|
196
196
|
new PolicyStatement({
|
|
197
197
|
actions: ['lambda:InvokeFunction'],
|
|
@@ -204,7 +204,7 @@ export class LambdaWithIamAccess extends CommonConstruct {
|
|
|
204
204
|
if (this.props.lambda.lambdaAliases && !_.isEmpty(this.props.lambda.lambdaAliases)) {
|
|
205
205
|
_.forEach(this.props.lambda.lambdaAliases, (alias, index) => {
|
|
206
206
|
new Policy(this, `${this.id}-alias-user-policy`, {
|
|
207
|
-
policyName: `${this.id}
|
|
207
|
+
policyName: this.resourceNameFormatter(`${this.id}--alias-policy-${index}`),
|
|
208
208
|
statements: [
|
|
209
209
|
new PolicyStatement({
|
|
210
210
|
actions: ['lambda:InvokeFunction'],
|
|
@@ -230,9 +230,9 @@ export class LambdaWithIamAccess extends CommonConstruct {
|
|
|
230
230
|
* @summary Method to create iam secret for the lambda function
|
|
231
231
|
*/
|
|
232
232
|
protected createIamSecretForLambdaFunction() {
|
|
233
|
-
this.lambdaUserAccessSecret =
|
|
234
|
-
this,
|
|
233
|
+
this.lambdaUserAccessSecret = this.secretsManager.createSecret(
|
|
235
234
|
`${this.id}-lambda-user-secret-${this.props.stage}`,
|
|
235
|
+
this,
|
|
236
236
|
this.props.lambdaSecret
|
|
237
237
|
)
|
|
238
238
|
|
|
@@ -296,13 +296,11 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
296
296
|
enableECSManagedTags: true,
|
|
297
297
|
healthCheckGracePeriod: Duration.seconds(60),
|
|
298
298
|
listenerPort: this.props.siteTask.listenerPort,
|
|
299
|
-
loadBalancerName: this.props.siteTask.loadBalancerName
|
|
300
|
-
? `${this.props.siteTask.loadBalancerName}-${this.props.stage}`
|
|
301
|
-
: `${this.id}-${this.props.stage}`,
|
|
299
|
+
loadBalancerName: this.resourceNameFormatter(this.props.siteTask.loadBalancerName ?? this.id),
|
|
302
300
|
maxHealthyPercent: this.props.siteTask.maxHealthyPercent,
|
|
303
301
|
memoryLimitMiB: this.props.siteTask.memoryLimitMiB,
|
|
304
302
|
minHealthyPercent: this.props.siteTask.minHealthyPercent,
|
|
305
|
-
serviceName:
|
|
303
|
+
serviceName: this.resourceNameFormatter(this.props.siteTask.serviceName ?? this.id),
|
|
306
304
|
taskDefinition: this.props.siteTask.taskDefinition,
|
|
307
305
|
taskImageOptions: {
|
|
308
306
|
containerPort: this.props.siteTask.taskImageOptions?.containerPort,
|
|
@@ -402,7 +400,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
402
400
|
transitEncryption: this.props.siteFileSystem.transitEncryption,
|
|
403
401
|
transitEncryptionPort: this.props.siteFileSystem.transitEncryptionPort,
|
|
404
402
|
},
|
|
405
|
-
name:
|
|
403
|
+
name: this.resourceNameFormatter(this.props.siteFileSystem?.fileSystemName ?? this.id),
|
|
406
404
|
})
|
|
407
405
|
|
|
408
406
|
if (this.props.siteTask.mountPoints && !_.isEmpty(this.props.siteTask.mountPoints)) {
|
|
@@ -410,7 +408,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
410
408
|
this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
|
|
411
409
|
containerPath: mountPoint.containerPath,
|
|
412
410
|
readOnly: mountPoint.readOnly,
|
|
413
|
-
sourceVolume:
|
|
411
|
+
sourceVolume: this.resourceNameFormatter(this.props.siteFileSystem?.fileSystemName ?? this.id),
|
|
414
412
|
})
|
|
415
413
|
})
|
|
416
414
|
}
|
|
@@ -430,8 +428,10 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
430
428
|
}
|
|
431
429
|
|
|
432
430
|
protected createSiteCachePolicy(id: string, siteCachePolicy: SiteCachePolicyProps) {
|
|
431
|
+
if (!siteCachePolicy.cachePolicyName) throw `SiteCachePolicy cachePolicyName undefined for ${id}`
|
|
432
|
+
|
|
433
433
|
return new CachePolicy(this, `${id}`, {
|
|
434
|
-
cachePolicyName:
|
|
434
|
+
cachePolicyName: this.resourceNameFormatter(siteCachePolicy.cachePolicyName),
|
|
435
435
|
comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
436
436
|
cookieBehavior: siteCachePolicy.cookieBehavior,
|
|
437
437
|
enableAcceptEncodingBrotli: siteCachePolicy.enableAcceptEncodingBrotli,
|
|
@@ -453,11 +453,14 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
453
453
|
|
|
454
454
|
protected createSiteOriginRequestPolicy() {
|
|
455
455
|
if (!this.props.siteOriginRequestPolicy) return
|
|
456
|
+
if (!this.props.siteOriginRequestPolicy.originRequestPolicyName)
|
|
457
|
+
throw `SiteOriginRequestPolicy originRequestPolicyName undefined for ${this.id}`
|
|
458
|
+
|
|
456
459
|
this.siteOriginRequestPolicy = new OriginRequestPolicy(this, `${this.id}-sorp`, {
|
|
457
460
|
comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
458
461
|
cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
|
|
459
462
|
headerBehavior: this.props.siteOriginRequestPolicy.headerBehavior,
|
|
460
|
-
originRequestPolicyName:
|
|
463
|
+
originRequestPolicyName: this.resourceNameFormatter(this.props.siteOriginRequestPolicy.originRequestPolicyName),
|
|
461
464
|
queryStringBehavior: this.props.siteOriginRequestPolicy.queryStringBehavior,
|
|
462
465
|
})
|
|
463
466
|
|
|
@@ -468,10 +471,13 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
468
471
|
|
|
469
472
|
protected createResponseHeaderPolicy(props: SiteResponseHeadersPolicyProps) {
|
|
470
473
|
if (!props) return undefined
|
|
474
|
+
if (!props.responseHeadersPolicyName)
|
|
475
|
+
throw `SiteResponseHeadersPolicy responseHeadersPolicyName undefined for ${this.id}`
|
|
476
|
+
|
|
471
477
|
return new ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
|
|
472
478
|
...props,
|
|
473
479
|
comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
474
|
-
responseHeadersPolicyName:
|
|
480
|
+
responseHeadersPolicyName: this.resourceNameFormatter(props.responseHeadersPolicyName),
|
|
475
481
|
securityHeadersBehavior: {
|
|
476
482
|
...props.securityHeadersBehavior,
|
|
477
483
|
strictTransportSecurity: {
|