@gradientedge/cdk-utils 9.9.0 → 9.10.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/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 +3 -1
- 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 +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 +1 -1
- 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 +34 -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 +1 -1
- 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 +7 -1
- 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 +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 +1 -1
- 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 +28 -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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { CfnTrailProps } from 'aws-cdk-lib/aws-cloudtrail'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
|
-
export interface CloudTrailProps extends CfnTrailProps {
|
|
6
|
+
export interface CloudTrailProps extends CfnTrailProps {
|
|
7
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
8
|
+
}
|
|
@@ -56,10 +56,11 @@ export class DynamodbManager {
|
|
|
56
56
|
*/
|
|
57
57
|
public createTableV2(id: string, scope: CommonConstruct, props: TablePropsV2) {
|
|
58
58
|
if (!props) throw `Table props undefined for ${id}`
|
|
59
|
+
if (!props.tableName) throw `Table tableName undefined for ${id}`
|
|
59
60
|
|
|
60
61
|
const table = new TableV2(scope, `${id}`, {
|
|
61
62
|
...props,
|
|
62
|
-
tableName:
|
|
63
|
+
tableName: scope.resourceNameFormatter(props.tableName, props.resourceNameOptions),
|
|
63
64
|
})
|
|
64
65
|
|
|
65
66
|
createCfnOutput(`${id}-tableName`, scope, table.tableName)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
3
|
import { TagProps } from '../../types'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -7,4 +8,6 @@ export interface TableProps extends dynamodb.TableProps {
|
|
|
7
8
|
tags?: TagProps[]
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export interface TablePropsV2 extends dynamodb.TablePropsV2 {
|
|
11
|
+
export interface TablePropsV2 extends dynamodb.TablePropsV2 {
|
|
12
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
13
|
+
}
|
|
@@ -148,6 +148,8 @@ export class EcsManager {
|
|
|
148
148
|
logGroup: ILogGroup
|
|
149
149
|
) {
|
|
150
150
|
if (!props) throw `Ecs Load balanced Fargate Service props undefined for ${id}`
|
|
151
|
+
if (!props.loadBalancerName) throw `Ecs loadBalancerName undefined for ${id}`
|
|
152
|
+
if (!props.serviceName) throw `Ecs serviceName undefined for ${id}`
|
|
151
153
|
if (!props.taskImageOptions)
|
|
152
154
|
throw `TaskImageOptions for Ecs Load balanced Fargate Service props undefined for ${id}`
|
|
153
155
|
|
|
@@ -157,12 +159,12 @@ export class EcsManager {
|
|
|
157
159
|
cluster,
|
|
158
160
|
enableECSManagedTags: true,
|
|
159
161
|
healthCheckGracePeriod: props.healthCheckGracePeriod ?? Duration.seconds(60),
|
|
160
|
-
loadBalancerName:
|
|
162
|
+
loadBalancerName: scope.resourceNameFormatter(props.loadBalancerName, props.resourceNameOptions),
|
|
161
163
|
runtimePlatform: {
|
|
162
164
|
cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? CpuArchitecture.X86_64,
|
|
163
165
|
operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? OperatingSystemFamily.LINUX,
|
|
164
166
|
},
|
|
165
|
-
serviceName:
|
|
167
|
+
serviceName: scope.resourceNameFormatter(props.serviceName, props.resourceNameOptions),
|
|
166
168
|
taskImageOptions: {
|
|
167
169
|
...props.taskImageOptions,
|
|
168
170
|
enableLogging: props.taskImageOptions?.enableLogging ?? true,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from 'aws-cdk-lib/aws-ecs'
|
|
9
9
|
import { ApplicationLoadBalancedFargateServiceProps } from 'aws-cdk-lib/aws-ecs-patterns'
|
|
10
10
|
import { HealthCheck as ElbHealthCheck } from 'aws-cdk-lib/aws-elasticloadbalancingv2'
|
|
11
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
11
12
|
import { TagProps } from '../../types'
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -54,4 +55,5 @@ export interface EcsApplicationLoadBalancedFargateServiceProps extends Applicati
|
|
|
54
55
|
logging?: AwsLogDriverProps
|
|
55
56
|
mountPoints?: MountPoint[]
|
|
56
57
|
siteScaling?: EcsScalingProps
|
|
58
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
57
59
|
}
|
|
@@ -54,11 +54,12 @@ export class EfsManager {
|
|
|
54
54
|
vpcSubnets?: SubnetSelection
|
|
55
55
|
) {
|
|
56
56
|
if (!props) throw `EFS props undefined for ${id}`
|
|
57
|
+
if (!props.fileSystemName) throw `EFS fileSystemName undefined for ${id}`
|
|
57
58
|
|
|
58
59
|
const fileSystemId = props.provisionNewOnDeployment ? `${id}-${new Date().getMilliseconds()}` : `${id}`
|
|
59
60
|
const fileSystem = new FileSystem(scope, `${fileSystemId}`, {
|
|
60
61
|
...props,
|
|
61
|
-
fileSystemName: props.fileSystemName
|
|
62
|
+
fileSystemName: scope.resourceNameFormatter(props.fileSystemName, props.resourceNameOptions),
|
|
62
63
|
lifecyclePolicy: props.lifecyclePolicy ?? LifecyclePolicy.AFTER_7_DAYS,
|
|
63
64
|
outOfInfrequentAccessPolicy: props.outOfInfrequentAccessPolicy ?? OutOfInfrequentAccessPolicy.AFTER_1_ACCESS,
|
|
64
65
|
performanceMode: props.performanceMode ?? PerformanceMode.GENERAL_PURPOSE,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AccessPointOptions, FileSystemProps } from 'aws-cdk-lib/aws-efs'
|
|
2
1
|
import { AuthorizationConfig } from 'aws-cdk-lib/aws-ecs'
|
|
2
|
+
import { AccessPointOptions, FileSystemProps } from 'aws-cdk-lib/aws-efs'
|
|
3
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
*/
|
|
@@ -9,6 +10,7 @@ export interface EfsFileSystemProps extends FileSystemProps {
|
|
|
9
10
|
rootDirectory?: string
|
|
10
11
|
transitEncryption?: string
|
|
11
12
|
transitEncryptionPort?: number
|
|
13
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -38,6 +38,7 @@ export class EksManager {
|
|
|
38
38
|
vpc: IVpc
|
|
39
39
|
) {
|
|
40
40
|
if (!props) throw `EksCluster props undefined for ${id}`
|
|
41
|
+
if (!props.clusterName) throw `EksCluster clusterName undefined for ${id}`
|
|
41
42
|
|
|
42
43
|
const appLabel = { app: `${id}`.toLowerCase() }
|
|
43
44
|
|
|
@@ -81,7 +82,7 @@ export class EksManager {
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
const cluster = new Cluster(scope, `${id}Cluster`, {
|
|
84
|
-
clusterName:
|
|
85
|
+
clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
|
|
85
86
|
defaultCapacity: props.appCapacity,
|
|
86
87
|
defaultCapacityInstance: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE),
|
|
87
88
|
version: KubernetesVersion.V1_27,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ClusterProps } from 'aws-cdk-lib/aws-eks'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
6
|
export interface EksClusterProps extends ClusterProps {
|
|
6
7
|
appCapacity: number
|
|
7
8
|
appContainerPort: number
|
|
9
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
8
10
|
}
|
|
@@ -54,13 +54,14 @@ export class ElastiCacheManager {
|
|
|
54
54
|
logDeliveryConfigurations?: any
|
|
55
55
|
) {
|
|
56
56
|
if (!props) throw `ElastiCache props undefined for ${id}`
|
|
57
|
+
if (!props.clusterName) throw `ElastiCache clusterName undefined for ${id}`
|
|
57
58
|
|
|
58
59
|
const subnetGroup = this.createElastiCacheSubnetGroup(`${id}-subnetGroup`, scope, subnetIds)
|
|
59
60
|
|
|
60
61
|
const elasticacheCluster = new CfnCacheCluster(scope, `${id}`, {
|
|
61
62
|
...props,
|
|
62
63
|
cacheSubnetGroupName: subnetGroup.cacheSubnetGroupName,
|
|
63
|
-
clusterName:
|
|
64
|
+
clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
|
|
64
65
|
logDeliveryConfigurations,
|
|
65
66
|
vpcSecurityGroupIds: securityGroupIds,
|
|
66
67
|
})
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { CfnCacheClusterProps, CfnReplicationGroupProps } from 'aws-cdk-lib/aws-elasticache'
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
|
-
export interface ElastiCacheProps extends CfnCacheClusterProps {
|
|
6
|
+
export interface ElastiCacheProps extends CfnCacheClusterProps {
|
|
7
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
8
|
+
}
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
*/
|
|
@@ -43,10 +43,11 @@ export class EventManager {
|
|
|
43
43
|
*/
|
|
44
44
|
public createEventBus(id: string, scope: CommonConstruct, props: EventBusProps) {
|
|
45
45
|
if (!props) throw `EventBus props undefined for ${id}`
|
|
46
|
+
if (!props.eventBusName) throw `EventBus eventBusName undefined for ${id}`
|
|
46
47
|
|
|
47
48
|
const eventBus = new EventBus(scope, `${id}`, {
|
|
48
49
|
...props,
|
|
49
|
-
eventBusName:
|
|
50
|
+
eventBusName: scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions),
|
|
50
51
|
})
|
|
51
52
|
|
|
52
53
|
createCfnOutput(`${id}-eventBusName`, scope, `${props.eventBusName}-${scope.props.stage}`)
|
|
@@ -71,11 +72,12 @@ export class EventManager {
|
|
|
71
72
|
targets?: IRuleTarget[]
|
|
72
73
|
) {
|
|
73
74
|
if (!props) throw `EventRule props undefined for ${id}`
|
|
75
|
+
if (!props.ruleName) throw `EventRule ruleName undefined for ${id}`
|
|
74
76
|
|
|
75
77
|
const rule = new Rule(scope, `${id}`, {
|
|
76
78
|
...props,
|
|
77
79
|
eventBus,
|
|
78
|
-
ruleName:
|
|
80
|
+
ruleName: scope.resourceNameFormatter(props.ruleName, props.resourceNameOptions),
|
|
79
81
|
})
|
|
80
82
|
|
|
81
83
|
if (targets && !_.isEmpty(targets)) {
|
|
@@ -116,23 +118,30 @@ export class EventManager {
|
|
|
116
118
|
scheduleExpression?: string
|
|
117
119
|
) {
|
|
118
120
|
if (!props) throw `EventRule props undefined for ${id}`
|
|
121
|
+
if (!props.name) throw `EventRule name undefined for ${id}`
|
|
119
122
|
|
|
120
123
|
const eventRule = new CfnRule(scope, `${id}`, {
|
|
121
124
|
...props,
|
|
122
125
|
description: 'Rule to send notification to lambda function target',
|
|
123
126
|
eventBusName,
|
|
124
127
|
eventPattern,
|
|
125
|
-
name:
|
|
128
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
126
129
|
scheduleExpression,
|
|
127
130
|
targets: [
|
|
128
131
|
{
|
|
129
132
|
arn: lambdaFunction.functionArn,
|
|
130
|
-
id:
|
|
133
|
+
id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
131
134
|
input: props.input ?? undefined,
|
|
132
135
|
},
|
|
133
136
|
],
|
|
134
137
|
})
|
|
135
138
|
|
|
139
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
140
|
+
_.forEach(props.tags, tag => {
|
|
141
|
+
Tags.of(eventRule).add(tag.key, tag.value)
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
136
145
|
new CfnPermission(scope, `${id}LambdaPermission`, {
|
|
137
146
|
action: 'lambda:InvokeFunction',
|
|
138
147
|
functionName: lambdaFunction.functionName,
|
|
@@ -168,12 +177,13 @@ export class EventManager {
|
|
|
168
177
|
eventPattern?: any
|
|
169
178
|
) {
|
|
170
179
|
if (!props) throw `EventRule props undefined for ${id}`
|
|
180
|
+
if (!props.name) throw `EventRule name undefined for ${id}`
|
|
171
181
|
|
|
172
182
|
const eventRule = new CfnRule(scope, `${id}`, {
|
|
173
183
|
...props,
|
|
174
184
|
description: 'Rule to send notification on new objects in data bucket to ecs task target',
|
|
175
185
|
eventPattern,
|
|
176
|
-
name:
|
|
186
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
177
187
|
targets: [
|
|
178
188
|
{
|
|
179
189
|
arn: cluster.clusterArn,
|
|
@@ -185,7 +195,7 @@ export class EventManager {
|
|
|
185
195
|
taskCount: 1,
|
|
186
196
|
taskDefinitionArn: task.taskDefinitionArn,
|
|
187
197
|
},
|
|
188
|
-
id:
|
|
198
|
+
id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
189
199
|
roleArn: role instanceof Role ? role.roleArn : role.attrArn,
|
|
190
200
|
},
|
|
191
201
|
],
|
|
@@ -212,6 +222,9 @@ export class EventManager {
|
|
|
212
222
|
sourceQueue: IQueue,
|
|
213
223
|
targetStepFunction: IStateMachine
|
|
214
224
|
) {
|
|
225
|
+
if (!props) throw `Pipe props undefined for ${id}`
|
|
226
|
+
if (!props.name) throw `Pipe name undefined for ${id}`
|
|
227
|
+
|
|
215
228
|
const pipeRole = scope.iamManager.createRoleForSqsToSfnPipe(
|
|
216
229
|
`${id}-role`,
|
|
217
230
|
scope,
|
|
@@ -221,7 +234,7 @@ export class EventManager {
|
|
|
221
234
|
|
|
222
235
|
const pipe = new CfnPipe(scope, `${id}`, {
|
|
223
236
|
...props,
|
|
224
|
-
name:
|
|
237
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
225
238
|
roleArn: pipeRole.roleArn,
|
|
226
239
|
source: sourceQueue.queueArn,
|
|
227
240
|
sourceParameters: {
|
|
@@ -269,6 +282,9 @@ export class EventManager {
|
|
|
269
282
|
sourceQueue: IQueue,
|
|
270
283
|
targetLambdaFunction: IFunction
|
|
271
284
|
) {
|
|
285
|
+
if (!props) throw `Pipe props undefined for ${id}`
|
|
286
|
+
if (!props.name) throw `Pipe name undefined for ${id}`
|
|
287
|
+
|
|
272
288
|
const pipeRole = scope.iamManager.createRoleForSqsToLambdaPipe(
|
|
273
289
|
`${id}-role`,
|
|
274
290
|
scope,
|
|
@@ -278,7 +294,7 @@ export class EventManager {
|
|
|
278
294
|
|
|
279
295
|
const pipe = new CfnPipe(scope, `${id}`, {
|
|
280
296
|
...props,
|
|
281
|
-
name:
|
|
297
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
282
298
|
roleArn: pipeRole.roleArn,
|
|
283
299
|
source: sourceQueue.queueArn,
|
|
284
300
|
sourceParameters: {
|
|
@@ -323,6 +339,9 @@ export class EventManager {
|
|
|
323
339
|
sourceDynamoDbStreamArn: string,
|
|
324
340
|
targetLambdaFunction: IFunction
|
|
325
341
|
) {
|
|
342
|
+
if (!props) throw `Pipe props undefined for ${id}`
|
|
343
|
+
if (!props.name) throw `Pipe name undefined for ${id}`
|
|
344
|
+
|
|
326
345
|
const pipeRole = scope.iamManager.createRoleForDynamoDbToLambdaPipe(
|
|
327
346
|
`${id}-role`,
|
|
328
347
|
scope,
|
|
@@ -332,7 +351,7 @@ export class EventManager {
|
|
|
332
351
|
|
|
333
352
|
const pipe = new CfnPipe(scope, `${id}`, {
|
|
334
353
|
...props,
|
|
335
|
-
name:
|
|
354
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
336
355
|
roleArn: pipeRole.roleArn,
|
|
337
356
|
source: sourceDynamoDbStreamArn,
|
|
338
357
|
sourceParameters: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CfnPipeProps } from 'aws-cdk-lib/aws-pipes'
|
|
2
1
|
import { CfnRuleProps, EventBusProps as EBProps, RuleProps as EBRuleProps } from 'aws-cdk-lib/aws-events'
|
|
2
|
+
import { CfnPipeProps } from 'aws-cdk-lib/aws-pipes'
|
|
3
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
3
4
|
import { TagProps } from '../../types'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -10,6 +11,7 @@ export interface SqsToSfnPipeProps extends CfnPipeProps {
|
|
|
10
11
|
sfnInvocationType?: string
|
|
11
12
|
sqsBatchSize?: number
|
|
12
13
|
sqsMaximumBatchingWindowInSeconds?: number
|
|
14
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -19,11 +21,13 @@ export interface SqsToLambdaPipeProps extends CfnPipeProps {
|
|
|
19
21
|
sqsBatchSize?: number
|
|
20
22
|
lambdaInputTemplate?: string
|
|
21
23
|
sqsMaximumBatchingWindowInSeconds?: number
|
|
24
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
*/
|
|
26
29
|
export interface EventRuleProps extends EBRuleProps {
|
|
30
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
27
31
|
tags?: TagProps[]
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -31,11 +35,15 @@ export interface EventRuleProps extends EBRuleProps {
|
|
|
31
35
|
*/
|
|
32
36
|
export interface RuleProps extends CfnRuleProps {
|
|
33
37
|
input?: string
|
|
38
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
39
|
+
tags?: TagProps[]
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
/**
|
|
37
43
|
*/
|
|
38
|
-
export interface EventBusProps extends EBProps {
|
|
44
|
+
export interface EventBusProps extends EBProps {
|
|
45
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
46
|
+
}
|
|
39
47
|
|
|
40
48
|
/**
|
|
41
49
|
}
|
|
@@ -44,4 +52,5 @@ export interface DynamoDbToLambdaPipeProps extends CfnPipeProps {
|
|
|
44
52
|
pipeFilterPattern?: any
|
|
45
53
|
dynamoDbBatchSize?: number
|
|
46
54
|
dynamoDbStartingPosition: string
|
|
55
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
47
56
|
}
|
|
@@ -33,10 +33,13 @@ export class EvidentlyManager {
|
|
|
33
33
|
* @param props the project properties
|
|
34
34
|
*/
|
|
35
35
|
public createProject(id: string, scope: CommonConstruct, props: EvidentlyProjectProps) {
|
|
36
|
+
if (!props) throw `EvidentlyProject props undefined for ${id}`
|
|
37
|
+
if (!props.name) throw `EvidentlyProject name undefined for ${id}`
|
|
38
|
+
|
|
36
39
|
const project = new CfnProject(scope, `${id}`, {
|
|
37
40
|
...props,
|
|
38
41
|
description: `${props.description} ${scope.props.stage}`,
|
|
39
|
-
name:
|
|
42
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
40
43
|
})
|
|
41
44
|
createCfnOutput(`${id}-projectArn`, scope, project.attrArn)
|
|
42
45
|
createCfnOutput(`${id}-projectName`, scope, project.name)
|
|
@@ -50,6 +53,8 @@ export class EvidentlyManager {
|
|
|
50
53
|
* @param props the feature properties
|
|
51
54
|
*/
|
|
52
55
|
public createFeature(id: string, scope: CommonConstruct, props: EvidentlyFeatureProps) {
|
|
56
|
+
if (!props) throw `EvidentlyFeature props undefined for ${id}`
|
|
57
|
+
|
|
53
58
|
const feature = new CfnFeature(scope, `${id}`, props)
|
|
54
59
|
createCfnOutput(`${id}-featureArn`, scope, feature.attrArn)
|
|
55
60
|
createCfnOutput(`${id}-featureName`, scope, feature.name)
|
|
@@ -63,10 +68,13 @@ export class EvidentlyManager {
|
|
|
63
68
|
* @param props the launch properties
|
|
64
69
|
*/
|
|
65
70
|
public createLaunch(id: string, scope: CommonConstruct, props: EvidentlyLaunchProps) {
|
|
71
|
+
if (!props) throw `EvidentlyLaunch props undefined for ${id}`
|
|
72
|
+
if (!props.name) throw `EvidentlyLaunch name undefined for ${id}`
|
|
73
|
+
|
|
66
74
|
const launch = new CfnLaunch(scope, `${id}`, {
|
|
67
75
|
...props,
|
|
68
76
|
description: `${props.description} ${scope.props.stage}`,
|
|
69
|
-
name:
|
|
77
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
70
78
|
})
|
|
71
79
|
createCfnOutput(`${id}-launchArn`, scope, launch.attrArn)
|
|
72
80
|
createCfnOutput(`${id}-launchName`, scope, launch.name)
|
|
@@ -80,10 +88,13 @@ export class EvidentlyManager {
|
|
|
80
88
|
* @param props the experiment properties
|
|
81
89
|
*/
|
|
82
90
|
public createExperiment(id: string, scope: CommonConstruct, props: EvidentlyExperimentProps) {
|
|
91
|
+
if (!props) throw `EvidentlyExperiment props undefined for ${id}`
|
|
92
|
+
if (!props.name) throw `EvidentlyExperiment name undefined for ${id}`
|
|
93
|
+
|
|
83
94
|
const experiment = new CfnExperiment(scope, `${id}`, {
|
|
84
95
|
...props,
|
|
85
96
|
description: `${props.description} ${scope.props.stage}`,
|
|
86
|
-
name:
|
|
97
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
87
98
|
})
|
|
88
99
|
createCfnOutput(`${id}-experimentArn`, scope, experiment.attrArn)
|
|
89
100
|
createCfnOutput(`${id}-experimentName`, scope, experiment.name)
|
|
@@ -97,10 +108,13 @@ export class EvidentlyManager {
|
|
|
97
108
|
* @param props the segment properties
|
|
98
109
|
*/
|
|
99
110
|
public createSegment(id: string, scope: CommonConstruct, props: EvidentlySegmentProps) {
|
|
111
|
+
if (!props) throw `EvidentlySegment props undefined for ${id}`
|
|
112
|
+
if (!props.name) throw `EvidentlySegment name undefined for ${id}`
|
|
113
|
+
|
|
100
114
|
const segment = new CfnSegment(scope, `${id}`, {
|
|
101
115
|
...props,
|
|
102
116
|
description: `${props.description} ${scope.props.stage}`,
|
|
103
|
-
name:
|
|
117
|
+
name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
|
|
104
118
|
})
|
|
105
119
|
createCfnOutput(`${id}-segmentArn`, scope, segment.attrArn)
|
|
106
120
|
createCfnOutput(`${id}-segmentName`, scope, segment.name)
|
|
@@ -5,10 +5,13 @@ import {
|
|
|
5
5
|
CfnProjectProps,
|
|
6
6
|
CfnSegmentProps,
|
|
7
7
|
} from 'aws-cdk-lib/aws-evidently'
|
|
8
|
+
import { ResourceNameFormatterProps } from '../../common'
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
*/
|
|
11
|
-
export interface EvidentlyProjectProps extends CfnProjectProps {
|
|
12
|
+
export interface EvidentlyProjectProps extends CfnProjectProps {
|
|
13
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
14
|
+
}
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
*/
|
|
@@ -16,12 +19,18 @@ export interface EvidentlyFeatureProps extends CfnFeatureProps {}
|
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
*/
|
|
19
|
-
export interface EvidentlyLaunchProps extends CfnLaunchProps {
|
|
22
|
+
export interface EvidentlyLaunchProps extends CfnLaunchProps {
|
|
23
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
24
|
+
}
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
*/
|
|
23
|
-
export interface EvidentlyExperimentProps extends CfnExperimentProps {
|
|
28
|
+
export interface EvidentlyExperimentProps extends CfnExperimentProps {
|
|
29
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
30
|
+
}
|
|
24
31
|
|
|
25
32
|
/**
|
|
26
33
|
*/
|
|
27
|
-
export interface EvidentlySegmentProps extends CfnSegmentProps {
|
|
34
|
+
export interface EvidentlySegmentProps extends CfnSegmentProps {
|
|
35
|
+
resourceNameOptions?: ResourceNameFormatterProps
|
|
36
|
+
}
|
|
@@ -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)
|