@gradientedge/cdk-utils 9.11.0 → 9.13.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/dist/src/lib/aws/common/index.d.ts +1 -0
- package/dist/src/lib/aws/common/index.js +1 -0
- package/dist/src/lib/aws/common/resource-name-formatter.js +2 -0
- package/dist/src/lib/aws/common/stack.d.ts +2 -0
- package/dist/src/lib/aws/common/stack.js +2 -0
- package/dist/src/lib/aws/common/types.d.ts +4 -0
- package/dist/src/lib/aws/construct/rest-api-lambda-with-cache/main.js +1 -1
- package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +2 -2
- package/dist/src/lib/aws/services/dynamodb/main.js +8 -1
- package/dist/src/lib/aws/services/dynamodb/types.d.ts +2 -0
- package/dist/src/lib/aws/services/key-management-service/main.js +3 -1
- package/dist/src/lib/aws/services/key-management-service/types.d.ts +2 -0
- package/dist/src/lib/aws/services/simple-storage-service/main.js +1 -2
- package/dist/src/lib/aws/services/systems-manager/main.d.ts +3 -3
- package/dist/src/lib/aws/services/systems-manager/main.js +3 -1
- package/dist/src/lib/aws/services/systems-manager/types.d.ts +5 -0
- package/dist/src/lib/aws/services/virtual-private-cloud/main.d.ts +2 -1
- package/dist/src/lib/aws/services/virtual-private-cloud/main.js +8 -5
- package/package.json +1 -1
- package/src/lib/aws/common/index.ts +1 -0
- package/src/lib/aws/common/resource-name-formatter.ts +2 -0
- package/src/lib/aws/common/stack.ts +2 -0
- package/src/lib/aws/common/types.ts +4 -0
- package/src/lib/aws/construct/rest-api-lambda-with-cache/main.ts +6 -1
- package/src/lib/aws/construct/site-with-ecs-backend/main.ts +7 -2
- package/src/lib/aws/services/dynamodb/main.ts +8 -1
- package/src/lib/aws/services/dynamodb/types.ts +2 -0
- package/src/lib/aws/services/key-management-service/main.ts +2 -1
- package/src/lib/aws/services/key-management-service/types.ts +4 -1
- package/src/lib/aws/services/simple-storage-service/main.ts +5 -2
- package/src/lib/aws/services/systems-manager/main.ts +5 -4
- package/src/lib/aws/services/systems-manager/types.ts +7 -0
- package/src/lib/aws/services/virtual-private-cloud/main.ts +11 -5
|
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./construct"), exports);
|
|
18
|
+
__exportStar(require("./resource-name-formatter"), exports);
|
|
18
19
|
__exportStar(require("./stack"), exports);
|
|
19
20
|
__exportStar(require("./types"), exports);
|
|
@@ -16,9 +16,11 @@ class ResourceNameFormatter extends constructs_1.Construct {
|
|
|
16
16
|
*/
|
|
17
17
|
format(resourceName, options) {
|
|
18
18
|
const resourceNameElements = [];
|
|
19
|
+
resourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined);
|
|
19
20
|
resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix);
|
|
20
21
|
resourceNameElements.push(resourceName);
|
|
21
22
|
resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix);
|
|
23
|
+
resourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined);
|
|
22
24
|
resourceNameElements.push(this.props.stage);
|
|
23
25
|
return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-');
|
|
24
26
|
}
|
|
@@ -53,6 +53,8 @@ class CommonStack extends aws_cdk_lib_1.Stack {
|
|
|
53
53
|
name: props.stackName || 'cdk-utils',
|
|
54
54
|
nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
|
|
55
55
|
region: this.node.tryGetContext('region'),
|
|
56
|
+
globalPrefix: this.node.tryGetContext('globalPrefix'),
|
|
57
|
+
globalSuffix: this.node.tryGetContext('globalSuffix'),
|
|
56
58
|
resourcePrefix: this.node.tryGetContext('resourcePrefix'),
|
|
57
59
|
resourceSuffix: this.node.tryGetContext('resourceSuffix'),
|
|
58
60
|
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
@@ -7,6 +7,8 @@ import { BaseProps } from '../../common';
|
|
|
7
7
|
export interface CommonStackProps extends BaseProps, StackProps {
|
|
8
8
|
region: string;
|
|
9
9
|
resourceProjectIdentifier?: string;
|
|
10
|
+
globalPrefix?: string;
|
|
11
|
+
globalSuffix?: string;
|
|
10
12
|
resourcePrefix?: string;
|
|
11
13
|
resourceSuffix?: string;
|
|
12
14
|
logRetention?: RetentionDays;
|
|
@@ -17,6 +19,8 @@ export interface CommonStackProps extends BaseProps, StackProps {
|
|
|
17
19
|
nodejsRuntime?: Runtime;
|
|
18
20
|
}
|
|
19
21
|
export interface ResourceNameFormatterProps {
|
|
22
|
+
globalPrefix?: boolean;
|
|
23
|
+
globalSuffix?: boolean;
|
|
20
24
|
prefix?: string;
|
|
21
25
|
suffix?: string;
|
|
22
26
|
}
|
|
@@ -55,7 +55,7 @@ class RestApiLambdaWithCache extends __1.RestApiLambda {
|
|
|
55
55
|
this.restApivpc = this.vpcManager.retrieveCommonVpc(`${this.id}-vpc`, this, this.props.vpcName);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
this.restApivpc = this.vpcManager.createCommonVpc(this, this.props.restApiVpc, this.props.restApiVpc.vpcName);
|
|
58
|
+
this.restApivpc = this.vpcManager.createCommonVpc(`${this.id}-vpc`, this, this.props.restApiVpc, this.props.restApiVpc.vpcName);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -149,10 +149,10 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
149
149
|
*/
|
|
150
150
|
createVpc() {
|
|
151
151
|
if (this.props.useExistingVpc) {
|
|
152
|
-
this.siteVpc = this.vpcManager.retrieveCommonVpc(`${this.id}`, this, this.props.siteVpc.vpcName);
|
|
152
|
+
this.siteVpc = this.vpcManager.retrieveCommonVpc(`${this.id}-vpc`, this, this.props.siteVpc.vpcName);
|
|
153
153
|
}
|
|
154
154
|
else {
|
|
155
|
-
this.siteVpc = this.vpcManager.createCommonVpc(this, this.props.siteVpc, this.props.siteVpc.vpcName);
|
|
155
|
+
this.siteVpc = this.vpcManager.createCommonVpc(`${this.id}-vpc`, this, this.props.siteVpc, this.props.siteVpc.vpcName);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
@@ -34,9 +34,11 @@ class DynamodbManager {
|
|
|
34
34
|
createTable(id, scope, props) {
|
|
35
35
|
if (!props)
|
|
36
36
|
throw `Table props undefined for ${id}`;
|
|
37
|
+
if (!props.tableName)
|
|
38
|
+
throw `Table tableName undefined for ${id}`;
|
|
37
39
|
const table = new aws_dynamodb_1.Table(scope, `${id}`, {
|
|
38
40
|
...props,
|
|
39
|
-
tableName:
|
|
41
|
+
tableName: scope.resourceNameFormatter.format(props.tableName, props.resourceNameOptions),
|
|
40
42
|
});
|
|
41
43
|
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
42
44
|
lodash_1.default.forEach(props.tags, tag => {
|
|
@@ -62,6 +64,11 @@ class DynamodbManager {
|
|
|
62
64
|
...props,
|
|
63
65
|
tableName: scope.resourceNameFormatter.format(props.tableName, props.resourceNameOptions),
|
|
64
66
|
});
|
|
67
|
+
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
68
|
+
lodash_1.default.forEach(props.tags, tag => {
|
|
69
|
+
aws_cdk_lib_1.Tags.of(table).add(tag.key, tag.value);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
65
72
|
(0, utils_1.createCfnOutput)(`${id}-tableName`, scope, table.tableName);
|
|
66
73
|
(0, utils_1.createCfnOutput)(`${id}-tableArn`, scope, table.tableArn);
|
|
67
74
|
return table;
|
|
@@ -4,8 +4,10 @@ import { TagProps } from '../../types';
|
|
|
4
4
|
/**
|
|
5
5
|
*/
|
|
6
6
|
export interface TableProps extends dynamodb.TableProps {
|
|
7
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
7
8
|
tags?: TagProps[];
|
|
8
9
|
}
|
|
9
10
|
export interface TablePropsV2 extends dynamodb.TablePropsV2 {
|
|
10
11
|
resourceNameOptions?: ResourceNameFormatterProps;
|
|
12
|
+
tags?: TagProps[];
|
|
11
13
|
}
|
|
@@ -29,9 +29,11 @@ class KmsManager {
|
|
|
29
29
|
createKey(id, scope, props) {
|
|
30
30
|
if (!props)
|
|
31
31
|
throw `KMS Key props undefined for ${id}`;
|
|
32
|
+
if (!props.alias)
|
|
33
|
+
throw `KMS Key alias undefined for ${id}`;
|
|
32
34
|
const key = new aws_kms_1.Key(scope, `${id}`, {
|
|
33
35
|
...props,
|
|
34
|
-
alias:
|
|
36
|
+
alias: scope.resourceNameFormatter.format(props.alias, props.resourceNameOptions),
|
|
35
37
|
});
|
|
36
38
|
(0, utils_1.createCfnOutput)(`${id}-keyId`, scope, key.keyId);
|
|
37
39
|
(0, utils_1.createCfnOutput)(`${id}-keyArn`, scope, key.keyArn);
|
|
@@ -95,8 +95,7 @@ class S3Manager {
|
|
|
95
95
|
else {
|
|
96
96
|
let logBucket;
|
|
97
97
|
if (props.logBucketName) {
|
|
98
|
-
|
|
99
|
-
logBucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}-logs`, props.logBucketName);
|
|
98
|
+
logBucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}-logs`, S3Manager.determineBucketName(scope, props, props.logBucketName));
|
|
100
99
|
}
|
|
101
100
|
bucket = new aws_s3_1.Bucket(scope, `${id}-bucket`, {
|
|
102
101
|
...props,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { StringParameter
|
|
1
|
+
import { StringParameter } from 'aws-cdk-lib/aws-ssm';
|
|
2
2
|
import { AwsCustomResource } from 'aws-cdk-lib/custom-resources';
|
|
3
3
|
import { CommonConstruct } from '../../common';
|
|
4
|
-
import { SSMParameterReaderProps } from './types';
|
|
4
|
+
import { SSMParameterReaderProps, SSMStringParameterProps } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* @classdesc Provides operations on AWS Systems Manager.
|
|
7
7
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
@@ -26,7 +26,7 @@ export declare class SsmManager {
|
|
|
26
26
|
* @param scope scope in which this resource is defined
|
|
27
27
|
* @param props parameter props
|
|
28
28
|
*/
|
|
29
|
-
writeStringToParameters(id: string, scope: CommonConstruct, props:
|
|
29
|
+
writeStringToParameters(id: string, scope: CommonConstruct, props: SSMStringParameterProps): StringParameter;
|
|
30
30
|
/**
|
|
31
31
|
* Method to read a string parameter from the parameters store
|
|
32
32
|
* @param id scoped id of the resource
|
|
@@ -31,10 +31,12 @@ class SsmManager {
|
|
|
31
31
|
writeStringToParameters(id, scope, props) {
|
|
32
32
|
if (!props)
|
|
33
33
|
throw `Parameter props undefined for ${id}`;
|
|
34
|
+
if (!props.parameterName)
|
|
35
|
+
throw `Parameter parameterName undefined for ${id}`;
|
|
34
36
|
const parameter = new aws_ssm_1.StringParameter(scope, `${id}`, {
|
|
35
37
|
...props,
|
|
36
38
|
description: `${props.description} - ${scope.props.stage} stage`,
|
|
37
|
-
parameterName:
|
|
39
|
+
parameterName: scope.resourceNameFormatter.format(props.parameterName, props.resourceNameOptions),
|
|
38
40
|
});
|
|
39
41
|
(0, utils_1.createCfnOutput)(`${id}-parameterArn`, scope, parameter.parameterArn);
|
|
40
42
|
(0, utils_1.createCfnOutput)(`${id}-parameterName`, scope, parameter.parameterName);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { StringParameterProps } from 'aws-cdk-lib/aws-ssm';
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common';
|
|
1
3
|
/**
|
|
2
4
|
*/
|
|
3
5
|
export interface SSMParameterReaderProps {
|
|
4
6
|
parameterName: string;
|
|
5
7
|
region: string;
|
|
6
8
|
}
|
|
9
|
+
export interface SSMStringParameterProps extends StringParameterProps {
|
|
10
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
11
|
+
}
|
|
@@ -27,11 +27,12 @@ export declare class VpcManager {
|
|
|
27
27
|
createVpc(id: string, scope: CommonConstruct, props: VpcProps): Vpc;
|
|
28
28
|
/**
|
|
29
29
|
* @summary Method to create a common vpc
|
|
30
|
+
* @param id scoped id of the resource
|
|
30
31
|
* @param scope scope in which this resource is defined
|
|
31
32
|
* @param props
|
|
32
33
|
* @param vpcIdentifier optional identifier for VPC
|
|
33
34
|
*/
|
|
34
|
-
createCommonVpc(scope: CommonConstruct, props: VpcProps, vpcIdentifier?: string): Vpc;
|
|
35
|
+
createCommonVpc(id: string, scope: CommonConstruct, props: VpcProps, vpcIdentifier?: string): Vpc;
|
|
35
36
|
/**
|
|
36
37
|
* @summary Method to retrieve a common vpc
|
|
37
38
|
* @param id scoped id of the resource
|
|
@@ -53,7 +53,10 @@ class VpcManager {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
vpc = new aws_ec2_1.Vpc(scope, `${id}`,
|
|
56
|
+
vpc = new aws_ec2_1.Vpc(scope, `${id}`, {
|
|
57
|
+
...props,
|
|
58
|
+
vpcName,
|
|
59
|
+
});
|
|
57
60
|
}
|
|
58
61
|
(0, utils_1.createCfnOutput)(`${id}Id`, scope, vpc.vpcId);
|
|
59
62
|
(0, utils_1.createCfnOutput)(`${id}PublicSubnetIds`, scope, lodash_1.default.map(vpc.publicSubnets, subnet => subnet.subnetId).toString());
|
|
@@ -66,13 +69,14 @@ class VpcManager {
|
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
71
|
* @summary Method to create a common vpc
|
|
72
|
+
* @param id scoped id of the resource
|
|
69
73
|
* @param scope scope in which this resource is defined
|
|
70
74
|
* @param props
|
|
71
75
|
* @param vpcIdentifier optional identifier for VPC
|
|
72
76
|
*/
|
|
73
|
-
createCommonVpc(scope, props, vpcIdentifier) {
|
|
74
|
-
const vpc = this.createVpc(
|
|
75
|
-
aws_cdk_lib_1.Tags.of(vpc).add('Name', vpcIdentifier ?? CommonVpcIdentifier);
|
|
77
|
+
createCommonVpc(id, scope, props, vpcIdentifier) {
|
|
78
|
+
const vpc = this.createVpc(id, scope, props);
|
|
79
|
+
aws_cdk_lib_1.Tags.of(vpc).add('Name', scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier, props.resourceNameOptions));
|
|
76
80
|
return vpc;
|
|
77
81
|
}
|
|
78
82
|
/**
|
|
@@ -82,7 +86,6 @@ class VpcManager {
|
|
|
82
86
|
* @param vpcIdentifier optional identifier for VPC
|
|
83
87
|
*/
|
|
84
88
|
retrieveCommonVpc(id, scope, vpcIdentifier) {
|
|
85
|
-
const vpcName = scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier);
|
|
86
89
|
return aws_ec2_1.Vpc.fromLookup(scope, `${id}`, {
|
|
87
90
|
vpcName: scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier),
|
|
88
91
|
});
|
package/package.json
CHANGED
|
@@ -17,9 +17,11 @@ export class ResourceNameFormatter extends Construct {
|
|
|
17
17
|
*/
|
|
18
18
|
public format(resourceName: string, options?: ResourceNameFormatterProps) {
|
|
19
19
|
const resourceNameElements = []
|
|
20
|
+
resourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined)
|
|
20
21
|
resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
|
|
21
22
|
resourceNameElements.push(resourceName)
|
|
22
23
|
resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
|
|
24
|
+
resourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined)
|
|
23
25
|
resourceNameElements.push(this.props.stage)
|
|
24
26
|
return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-')
|
|
25
27
|
}
|
|
@@ -58,6 +58,8 @@ export class CommonStack extends Stack {
|
|
|
58
58
|
name: props.stackName || 'cdk-utils',
|
|
59
59
|
nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
|
|
60
60
|
region: this.node.tryGetContext('region'),
|
|
61
|
+
globalPrefix: this.node.tryGetContext('globalPrefix'),
|
|
62
|
+
globalSuffix: this.node.tryGetContext('globalSuffix'),
|
|
61
63
|
resourcePrefix: this.node.tryGetContext('resourcePrefix'),
|
|
62
64
|
resourceSuffix: this.node.tryGetContext('resourceSuffix'),
|
|
63
65
|
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
@@ -8,6 +8,8 @@ import { BaseProps } from '../../common'
|
|
|
8
8
|
export interface CommonStackProps extends BaseProps, StackProps {
|
|
9
9
|
region: string
|
|
10
10
|
resourceProjectIdentifier?: string
|
|
11
|
+
globalPrefix?: string
|
|
12
|
+
globalSuffix?: string
|
|
11
13
|
resourcePrefix?: string
|
|
12
14
|
resourceSuffix?: string
|
|
13
15
|
logRetention?: RetentionDays
|
|
@@ -19,6 +21,8 @@ export interface CommonStackProps extends BaseProps, StackProps {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface ResourceNameFormatterProps {
|
|
24
|
+
globalPrefix?: boolean
|
|
25
|
+
globalSuffix?: boolean
|
|
22
26
|
prefix?: string
|
|
23
27
|
suffix?: string
|
|
24
28
|
}
|
|
@@ -57,7 +57,12 @@ export abstract class RestApiLambdaWithCache extends RestApiLambda {
|
|
|
57
57
|
if (this.props.useExistingVpc) {
|
|
58
58
|
this.restApivpc = this.vpcManager.retrieveCommonVpc(`${this.id}-vpc`, this, this.props.vpcName)
|
|
59
59
|
} else {
|
|
60
|
-
this.restApivpc = this.vpcManager.createCommonVpc(
|
|
60
|
+
this.restApivpc = this.vpcManager.createCommonVpc(
|
|
61
|
+
`${this.id}-vpc`,
|
|
62
|
+
this,
|
|
63
|
+
this.props.restApiVpc,
|
|
64
|
+
this.props.restApiVpc.vpcName
|
|
65
|
+
)
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
|
|
@@ -213,9 +213,14 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
213
213
|
*/
|
|
214
214
|
protected createVpc() {
|
|
215
215
|
if (this.props.useExistingVpc) {
|
|
216
|
-
this.siteVpc = this.vpcManager.retrieveCommonVpc(`${this.id}`, this, this.props.siteVpc.vpcName)
|
|
216
|
+
this.siteVpc = this.vpcManager.retrieveCommonVpc(`${this.id}-vpc`, this, this.props.siteVpc.vpcName)
|
|
217
217
|
} else {
|
|
218
|
-
this.siteVpc = this.vpcManager.createCommonVpc(
|
|
218
|
+
this.siteVpc = this.vpcManager.createCommonVpc(
|
|
219
|
+
`${this.id}-vpc`,
|
|
220
|
+
this,
|
|
221
|
+
this.props.siteVpc,
|
|
222
|
+
this.props.siteVpc.vpcName
|
|
223
|
+
)
|
|
219
224
|
}
|
|
220
225
|
}
|
|
221
226
|
|
|
@@ -30,10 +30,11 @@ export class DynamodbManager {
|
|
|
30
30
|
*/
|
|
31
31
|
public createTable(id: string, scope: CommonConstruct, props: TableProps) {
|
|
32
32
|
if (!props) throw `Table props undefined for ${id}`
|
|
33
|
+
if (!props.tableName) throw `Table tableName undefined for ${id}`
|
|
33
34
|
|
|
34
35
|
const table = new Table(scope, `${id}`, {
|
|
35
36
|
...props,
|
|
36
|
-
tableName:
|
|
37
|
+
tableName: scope.resourceNameFormatter.format(props.tableName, props.resourceNameOptions),
|
|
37
38
|
})
|
|
38
39
|
|
|
39
40
|
if (props.tags && !_.isEmpty(props.tags)) {
|
|
@@ -63,6 +64,12 @@ export class DynamodbManager {
|
|
|
63
64
|
tableName: scope.resourceNameFormatter.format(props.tableName, props.resourceNameOptions),
|
|
64
65
|
})
|
|
65
66
|
|
|
67
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
68
|
+
_.forEach(props.tags, tag => {
|
|
69
|
+
Tags.of(table).add(tag.key, tag.value)
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
createCfnOutput(`${id}-tableName`, scope, table.tableName)
|
|
67
74
|
createCfnOutput(`${id}-tableArn`, scope, table.tableArn)
|
|
68
75
|
|
|
@@ -5,9 +5,11 @@ import { TagProps } from '../../types'
|
|
|
5
5
|
/**
|
|
6
6
|
*/
|
|
7
7
|
export interface TableProps extends dynamodb.TableProps {
|
|
8
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
8
9
|
tags?: TagProps[]
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export interface TablePropsV2 extends dynamodb.TablePropsV2 {
|
|
12
13
|
resourceNameOptions?: ResourceNameFormatterProps
|
|
14
|
+
tags?: TagProps[]
|
|
13
15
|
}
|
|
@@ -28,10 +28,11 @@ export class KmsManager {
|
|
|
28
28
|
*/
|
|
29
29
|
public createKey(id: string, scope: CommonConstruct, props: KmsKeyProps) {
|
|
30
30
|
if (!props) throw `KMS Key props undefined for ${id}`
|
|
31
|
+
if (!props.alias) throw `KMS Key alias undefined for ${id}`
|
|
31
32
|
|
|
32
33
|
const key = new Key(scope, `${id}`, {
|
|
33
34
|
...props,
|
|
34
|
-
alias:
|
|
35
|
+
alias: scope.resourceNameFormatter.format(props.alias, props.resourceNameOptions),
|
|
35
36
|
})
|
|
36
37
|
|
|
37
38
|
createCfnOutput(`${id}-keyId`, scope, key.keyId)
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { KeyProps } from 'aws-cdk-lib/aws-kms'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
|
-
export interface KmsKeyProps extends KeyProps {
|
|
6
|
+
export interface KmsKeyProps extends KeyProps {
|
|
7
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
8
|
+
}
|
|
@@ -99,8 +99,11 @@ export class S3Manager {
|
|
|
99
99
|
} else {
|
|
100
100
|
let logBucket
|
|
101
101
|
if (props.logBucketName) {
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
logBucket = Bucket.fromBucketName(
|
|
103
|
+
scope,
|
|
104
|
+
`${id}-logs`,
|
|
105
|
+
S3Manager.determineBucketName(scope, props, props.logBucketName)
|
|
106
|
+
)
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
bucket = new Bucket(scope, `${id}-bucket`, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StringParameter
|
|
1
|
+
import { StringParameter } from 'aws-cdk-lib/aws-ssm'
|
|
2
2
|
import {
|
|
3
3
|
AwsCustomResource,
|
|
4
4
|
AwsCustomResourcePolicy,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from 'aws-cdk-lib/custom-resources'
|
|
8
8
|
import { CommonConstruct } from '../../common'
|
|
9
9
|
import { createCfnOutput } from '../../utils'
|
|
10
|
-
import { SSMParameterReaderProps } from './types'
|
|
10
|
+
import { SSMParameterReaderProps, SSMStringParameterProps } from './types'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @classdesc Provides operations on AWS Systems Manager.
|
|
@@ -34,13 +34,14 @@ export class SsmManager {
|
|
|
34
34
|
* @param scope scope in which this resource is defined
|
|
35
35
|
* @param props parameter props
|
|
36
36
|
*/
|
|
37
|
-
public writeStringToParameters(id: string, scope: CommonConstruct, props:
|
|
37
|
+
public writeStringToParameters(id: string, scope: CommonConstruct, props: SSMStringParameterProps) {
|
|
38
38
|
if (!props) throw `Parameter props undefined for ${id}`
|
|
39
|
+
if (!props.parameterName) throw `Parameter parameterName undefined for ${id}`
|
|
39
40
|
|
|
40
41
|
const parameter = new StringParameter(scope, `${id}`, {
|
|
41
42
|
...props,
|
|
42
43
|
description: `${props.description} - ${scope.props.stage} stage`,
|
|
43
|
-
parameterName:
|
|
44
|
+
parameterName: scope.resourceNameFormatter.format(props.parameterName, props.resourceNameOptions),
|
|
44
45
|
})
|
|
45
46
|
|
|
46
47
|
createCfnOutput(`${id}-parameterArn`, scope, parameter.parameterArn)
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { StringParameterProps } from 'aws-cdk-lib/aws-ssm'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
*/
|
|
3
6
|
export interface SSMParameterReaderProps {
|
|
4
7
|
parameterName: string
|
|
5
8
|
region: string
|
|
6
9
|
}
|
|
10
|
+
|
|
11
|
+
export interface SSMStringParameterProps extends StringParameterProps {
|
|
12
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
13
|
+
}
|
|
@@ -49,7 +49,10 @@ export class VpcManager {
|
|
|
49
49
|
vpcName,
|
|
50
50
|
})
|
|
51
51
|
} else {
|
|
52
|
-
vpc = new Vpc(scope, `${id}`,
|
|
52
|
+
vpc = new Vpc(scope, `${id}`, {
|
|
53
|
+
...props,
|
|
54
|
+
vpcName,
|
|
55
|
+
})
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
createCfnOutput(`${id}Id`, scope, vpc.vpcId)
|
|
@@ -73,13 +76,17 @@ export class VpcManager {
|
|
|
73
76
|
|
|
74
77
|
/**
|
|
75
78
|
* @summary Method to create a common vpc
|
|
79
|
+
* @param id scoped id of the resource
|
|
76
80
|
* @param scope scope in which this resource is defined
|
|
77
81
|
* @param props
|
|
78
82
|
* @param vpcIdentifier optional identifier for VPC
|
|
79
83
|
*/
|
|
80
|
-
public createCommonVpc(scope: CommonConstruct, props: VpcProps, vpcIdentifier?: string) {
|
|
81
|
-
const vpc = this.createVpc(
|
|
82
|
-
Tags.of(vpc).add(
|
|
84
|
+
public createCommonVpc(id: string, scope: CommonConstruct, props: VpcProps, vpcIdentifier?: string) {
|
|
85
|
+
const vpc = this.createVpc(id, scope, props)
|
|
86
|
+
Tags.of(vpc).add(
|
|
87
|
+
'Name',
|
|
88
|
+
scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier, props.resourceNameOptions)
|
|
89
|
+
)
|
|
83
90
|
|
|
84
91
|
return vpc
|
|
85
92
|
}
|
|
@@ -91,7 +98,6 @@ export class VpcManager {
|
|
|
91
98
|
* @param vpcIdentifier optional identifier for VPC
|
|
92
99
|
*/
|
|
93
100
|
public retrieveCommonVpc(id: string, scope: CommonConstruct, vpcIdentifier?: string) {
|
|
94
|
-
const vpcName = scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier)
|
|
95
101
|
return Vpc.fromLookup(scope, `${id}`, {
|
|
96
102
|
vpcName: scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier),
|
|
97
103
|
})
|