@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,7 +1,7 @@
|
|
|
1
1
|
import { CfnOutput } from 'aws-cdk-lib';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
3
|
import { AcmManager, ApiManager, AppConfigManager, CloudFrontManager, CloudTrailManager, CloudWatchManager, CodeBuildManager, DynamodbManager, EcrManager, EcsManager, EfsManager, EksManager, ElastiCacheManager, EventManager, EventTargetManager, EvidentlyManager, IamManager, KmsManager, LambdaManager, LogManager, Route53Manager, S3Manager, SecretsManager, SfnManager, SnsManager, SqsManager, SsmManager, VpcManager, WafManager } from '../services';
|
|
4
|
-
import { CommonStackProps } from './types';
|
|
4
|
+
import { CommonStackProps, ResourceNameFormatterProps } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* @subcategory Construct
|
|
7
7
|
* @classdesc Common construct to use as a base for all higher level constructs.
|
|
@@ -48,6 +48,13 @@ export declare class CommonConstruct extends Construct {
|
|
|
48
48
|
wafManager: WafManager;
|
|
49
49
|
fullyQualifiedDomainName: string;
|
|
50
50
|
constructor(parent: Construct, id: string, props: CommonStackProps);
|
|
51
|
+
/**
|
|
52
|
+
* @summary Helper method to format a resource name based on the provided options
|
|
53
|
+
* @param resourceName the resource name to format
|
|
54
|
+
* @param options options to control the formatting of the resource name
|
|
55
|
+
* @returns The formatted resource name
|
|
56
|
+
*/
|
|
57
|
+
resourceNameFormatter(resourceName: string, options?: ResourceNameFormatterProps): string;
|
|
51
58
|
/**
|
|
52
59
|
* @summary Helper method to add CloudFormation outputs from the construct
|
|
53
60
|
* @param id scoped id of the resource
|
|
@@ -84,6 +84,20 @@ class CommonConstruct extends constructs_1.Construct {
|
|
|
84
84
|
this.wafManager = new services_1.WafManager();
|
|
85
85
|
this.determineFullyQualifiedDomain();
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* @summary Helper method to format a resource name based on the provided options
|
|
89
|
+
* @param resourceName the resource name to format
|
|
90
|
+
* @param options options to control the formatting of the resource name
|
|
91
|
+
* @returns The formatted resource name
|
|
92
|
+
*/
|
|
93
|
+
resourceNameFormatter(resourceName, options) {
|
|
94
|
+
const resourceNameElements = [];
|
|
95
|
+
resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix);
|
|
96
|
+
resourceNameElements.push(resourceName);
|
|
97
|
+
resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix);
|
|
98
|
+
resourceNameElements.push(this.props.stage);
|
|
99
|
+
return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-');
|
|
100
|
+
}
|
|
87
101
|
/**
|
|
88
102
|
* @summary Helper method to add CloudFormation outputs from the construct
|
|
89
103
|
* @param id scoped id of the resource
|
|
@@ -27,11 +27,14 @@ export declare class CommonStack extends Stack {
|
|
|
27
27
|
protected determineConstructProps(props: StackProps): {
|
|
28
28
|
domainName: any;
|
|
29
29
|
excludeDomainNameForBuckets: any;
|
|
30
|
+
excludeAccountNumberForBuckets: any;
|
|
30
31
|
extraContexts: any;
|
|
31
32
|
logRetention: any;
|
|
32
33
|
name: string;
|
|
33
34
|
nodejsRuntime: any;
|
|
34
35
|
region: any;
|
|
36
|
+
resourcePrefix: any;
|
|
37
|
+
resourceSuffix: any;
|
|
35
38
|
skipStageForARecords: any;
|
|
36
39
|
stackName: string | undefined;
|
|
37
40
|
stage: any;
|
|
@@ -47,11 +47,14 @@ class CommonStack extends aws_cdk_lib_1.Stack {
|
|
|
47
47
|
return {
|
|
48
48
|
domainName: this.node.tryGetContext('domainName'),
|
|
49
49
|
excludeDomainNameForBuckets: this.node.tryGetContext('excludeDomainNameForBuckets'),
|
|
50
|
+
excludeAccountNumberForBuckets: this.node.tryGetContext('excludeAccountNumberForBuckets'),
|
|
50
51
|
extraContexts: this.node.tryGetContext('extraContexts'),
|
|
51
52
|
logRetention: this.node.tryGetContext('logRetention'),
|
|
52
53
|
name: props.stackName || 'cdk-utils',
|
|
53
54
|
nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
|
|
54
55
|
region: this.node.tryGetContext('region'),
|
|
56
|
+
resourcePrefix: this.node.tryGetContext('resourcePrefix'),
|
|
57
|
+
resourceSuffix: this.node.tryGetContext('resourceSuffix'),
|
|
55
58
|
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
56
59
|
stackName: props.stackName,
|
|
57
60
|
stage: this.node.tryGetContext('stage'),
|
|
@@ -6,9 +6,17 @@ import { BaseProps } from '../../common';
|
|
|
6
6
|
*/
|
|
7
7
|
export interface CommonStackProps extends BaseProps, StackProps {
|
|
8
8
|
region: string;
|
|
9
|
+
resourceProjectIdentifier?: string;
|
|
10
|
+
resourcePrefix?: string;
|
|
11
|
+
resourceSuffix?: string;
|
|
9
12
|
logRetention?: RetentionDays;
|
|
10
13
|
defaultReservedLambdaConcurrentExecutions?: number;
|
|
11
14
|
defaultTracing?: Tracing;
|
|
12
15
|
excludeDomainNameForBuckets?: boolean;
|
|
16
|
+
excludeAccountNumberForBuckets?: boolean;
|
|
13
17
|
nodejsRuntime?: Runtime;
|
|
14
18
|
}
|
|
19
|
+
export interface ResourceNameFormatterProps {
|
|
20
|
+
prefix?: string;
|
|
21
|
+
suffix?: string;
|
|
22
|
+
}
|
|
@@ -84,6 +84,8 @@ class ApiToAnyTarget extends common_1.CommonConstruct {
|
|
|
84
84
|
this.apiToAnyTargetRestApi.api = aws_apigateway_1.RestApi.fromRestApiId(this, `${this.id}-rest-api`, aws_cdk_lib_1.Fn.importValue(this.props.api.importedRestApiRef));
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
+
if (!this.props.api.restApi?.restApiName)
|
|
88
|
+
throw `RestApi name undefined for ${this.id}`;
|
|
87
89
|
this.apiToAnyTargetRestApi.api = new aws_apigateway_1.RestApi(this, `${this.id}-rest-api`, {
|
|
88
90
|
cloudWatchRole: this.props.api.restApi?.cloudWatchRole ?? true,
|
|
89
91
|
defaultCorsPreflightOptions: {
|
|
@@ -109,8 +111,8 @@ class ApiToAnyTarget extends common_1.CommonConstruct {
|
|
|
109
111
|
endpointConfiguration: {
|
|
110
112
|
types: [this.isProductionStage() ? aws_apigateway_1.EndpointType.EDGE : aws_apigateway_1.EndpointType.REGIONAL],
|
|
111
113
|
},
|
|
112
|
-
restApiName: `${this.id}-rest-api-${this.props.stage}`,
|
|
113
114
|
...this.props.api.restApi,
|
|
115
|
+
restApiName: this.resourceNameFormatter(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
|
|
114
116
|
});
|
|
115
117
|
this.addCfnOutput(`${this.id}-restApiId`, this.apiToAnyTargetRestApi.api.restApiId);
|
|
116
118
|
this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToAnyTargetRestApi.api.root.resourceId);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BasePathMapping, DomainName, IAuthorizer, IResource, IRestApi, Integration, Method, MethodResponse, MockIntegration, Resource
|
|
1
|
+
import { BasePathMapping, DomainName, IAuthorizer, IResource, IRestApi, Integration, Method, MethodResponse, MockIntegration, Resource } from 'aws-cdk-lib/aws-apigateway';
|
|
2
2
|
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager';
|
|
3
3
|
import { LogGroup } from 'aws-cdk-lib/aws-logs';
|
|
4
4
|
import { IHostedZone } from 'aws-cdk-lib/aws-route53';
|
|
5
5
|
import { CommonStackProps } from '../../common';
|
|
6
|
-
import { AcmProps } from '../../services';
|
|
6
|
+
import { AcmProps, RestApigProps } from '../../services';
|
|
7
7
|
export interface ApiToAnyTargetRestApiType {
|
|
8
8
|
accessLogGroup: LogGroup;
|
|
9
9
|
api: IRestApi;
|
|
@@ -45,7 +45,7 @@ export interface ApiToAnyTargetRestApiProps {
|
|
|
45
45
|
importedRestApiRootResourceRef?: string;
|
|
46
46
|
methodErrorResponse: MethodResponse;
|
|
47
47
|
methodResponse: MethodResponse;
|
|
48
|
-
restApi:
|
|
48
|
+
restApi: RestApigProps;
|
|
49
49
|
useExisting: boolean;
|
|
50
50
|
withResource?: boolean;
|
|
51
51
|
}
|
|
@@ -301,6 +301,8 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
|
|
|
301
301
|
this.apiToEventBridgeTargetRestApi.api = aws_apigateway_1.RestApi.fromRestApiId(this, `${this.id}-rest-api`, aws_cdk_lib_1.Fn.importValue(this.props.api.importedRestApiRef));
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
|
+
if (!this.props.api.restApi?.restApiName)
|
|
305
|
+
throw `RestApi name undefined for ${this.id}`;
|
|
304
306
|
this.apiToEventBridgeTargetRestApi.api = new aws_apigateway_1.RestApi(this, `${this.id}-rest-api`, {
|
|
305
307
|
cloudWatchRole: this.props.api.restApi?.cloudWatchRole ?? true,
|
|
306
308
|
defaultCorsPreflightOptions: {
|
|
@@ -329,8 +331,8 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
|
|
|
329
331
|
endpointConfiguration: {
|
|
330
332
|
types: [aws_apigateway_1.EndpointType.REGIONAL],
|
|
331
333
|
},
|
|
332
|
-
restApiName: `${this.id}-rest-api-${this.props.stage}`,
|
|
333
334
|
...this.props.api.restApi,
|
|
335
|
+
restApiName: this.resourceNameFormatter(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
|
|
334
336
|
});
|
|
335
337
|
this.addCfnOutput(`${this.id}-restApiId`, this.apiToEventBridgeTargetRestApi.api.restApiId);
|
|
336
338
|
this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToEventBridgeTargetRestApi.api.root.resourceId);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { DomainName, IAuthorizer, Integration, IntegrationOptions, IntegrationResponse, IRestApi, Method, MethodResponse, Model, ModelOptions, Resource } from 'aws-cdk-lib/aws-apigateway';
|
|
2
|
+
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager';
|
|
1
3
|
import { IEventBus, Rule } from 'aws-cdk-lib/aws-events';
|
|
4
|
+
import { PolicyDocument, Role } from 'aws-cdk-lib/aws-iam';
|
|
5
|
+
import { AssetCode } from 'aws-cdk-lib/aws-lambda';
|
|
2
6
|
import { LogGroup } from 'aws-cdk-lib/aws-logs';
|
|
3
|
-
import { DomainName, IAuthorizer, Integration, IntegrationOptions, IntegrationResponse, IRestApi, Method, MethodResponse, Model, ModelOptions, Resource, RestApiProps } from 'aws-cdk-lib/aws-apigateway';
|
|
4
|
-
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager';
|
|
5
7
|
import { IHostedZone } from 'aws-cdk-lib/aws-route53';
|
|
6
8
|
import { ITopic } from 'aws-cdk-lib/aws-sns';
|
|
7
|
-
import { PolicyDocument, Role } from 'aws-cdk-lib/aws-iam';
|
|
8
9
|
import { CommonStackProps } from '../../common';
|
|
9
|
-
import { AcmProps, EventRuleProps, LambdaProps, LogProps } from '../../services';
|
|
10
|
-
import { AssetCode } from 'aws-cdk-lib/aws-lambda';
|
|
10
|
+
import { AcmProps, EventRuleProps, LambdaProps, LogProps, RestApigProps } from '../../services';
|
|
11
11
|
/**
|
|
12
12
|
*/
|
|
13
13
|
export interface ApiToEventBridgeTargetEventType {
|
|
@@ -61,7 +61,7 @@ export interface ApiToEventBridgeTargetRestApiProps {
|
|
|
61
61
|
methodResponse?: MethodResponse;
|
|
62
62
|
resource: string;
|
|
63
63
|
responseModel?: ModelOptions;
|
|
64
|
-
restApi?:
|
|
64
|
+
restApi?: RestApigProps;
|
|
65
65
|
useExisting: boolean;
|
|
66
66
|
withResource?: boolean;
|
|
67
67
|
}
|
|
@@ -271,7 +271,7 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
271
271
|
if (!this.props.api.withResource)
|
|
272
272
|
return;
|
|
273
273
|
this.apiDestinedRestApi.topic = this.snsManager.createLambdaNotificationService(`${this.id}-destined-topic`, this, {
|
|
274
|
-
topicName: `${this.id}-destined-topic
|
|
274
|
+
topicName: this.resourceNameFormatter(`${this.id}-destined-topic`),
|
|
275
275
|
}, this.apiDestinedLambda.function);
|
|
276
276
|
if (this.apiDestinedRestApi.role) {
|
|
277
277
|
this.apiDestinedRestApi.topic.grantPublish(this.apiDestinedRestApi.role);
|
|
@@ -413,6 +413,8 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
413
413
|
logGroupName: `/custom/api/${this.id}-destined-rest-api-access`,
|
|
414
414
|
removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
|
|
415
415
|
});
|
|
416
|
+
if (!this.props.api.restApi?.restApiName)
|
|
417
|
+
throw `RestApi name undefined for ${this.id}`;
|
|
416
418
|
this.apiDestinedRestApi.api = new aws_apigateway_1.RestApi(this, `${this.id}-sns-rest-api`, {
|
|
417
419
|
defaultCorsPreflightOptions: {
|
|
418
420
|
allowHeaders: aws_apigateway_1.Cors.DEFAULT_HEADERS,
|
|
@@ -435,8 +437,8 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
435
437
|
endpointConfiguration: {
|
|
436
438
|
types: [aws_apigateway_1.EndpointType.REGIONAL],
|
|
437
439
|
},
|
|
438
|
-
restApiName: `${this.id}-destined-rest-api-${this.props.stage}`,
|
|
439
440
|
...this.props.api,
|
|
441
|
+
restApiName: this.resourceNameFormatter(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
|
|
440
442
|
});
|
|
441
443
|
this.addCfnOutput(`${this.id}-restApiId`, this.apiDestinedRestApi.api.restApiId);
|
|
442
444
|
this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiDestinedRestApi.api.root.resourceId);
|
|
@@ -103,7 +103,7 @@ class ApiToLambdaTarget extends common_1.CommonConstruct {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
resolveApiToLambdaTargetFunction() {
|
|
106
|
-
this.apiToLambdaTargetRestApi.lambda = aws_lambda_1.Function.fromFunctionName(this, `${this.id}-lambda`, this.props.lambdaFunctionName);
|
|
106
|
+
this.apiToLambdaTargetRestApi.lambda = aws_lambda_1.Function.fromFunctionName(this, `${this.id}-lambda`, this.resourceNameFormatter(this.props.lambdaFunctionName));
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* @summary Method to create rest restApi for Api
|
|
@@ -8,7 +8,6 @@ const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
|
8
8
|
const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
|
|
9
9
|
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
10
10
|
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
11
|
-
const aws_secretsmanager_1 = require("aws-cdk-lib/aws-secretsmanager");
|
|
12
11
|
const lodash_1 = __importDefault(require("lodash"));
|
|
13
12
|
const common_1 = require("../../common");
|
|
14
13
|
const services_1 = require("../../services");
|
|
@@ -144,10 +143,10 @@ class LambdaWithIamAccess extends common_1.CommonConstruct {
|
|
|
144
143
|
*/
|
|
145
144
|
createIamUserForLambdaFunction() {
|
|
146
145
|
this.lambdaIamUser = new aws_iam_1.User(this, `${this.id}-lambda-user`, {
|
|
147
|
-
userName: `${this.id}-user
|
|
146
|
+
userName: this.resourceNameFormatter(`${this.id}-user`),
|
|
148
147
|
});
|
|
149
148
|
new aws_iam_1.Policy(this, `${this.id}-lambda-user-policy`, {
|
|
150
|
-
policyName: `${this.id}-policy
|
|
149
|
+
policyName: this.resourceNameFormatter(`${this.id}-policy`),
|
|
151
150
|
statements: [
|
|
152
151
|
new aws_iam_1.PolicyStatement({
|
|
153
152
|
actions: ['lambda:InvokeFunction'],
|
|
@@ -159,7 +158,7 @@ class LambdaWithIamAccess extends common_1.CommonConstruct {
|
|
|
159
158
|
if (this.props.lambda.lambdaAliases && !lodash_1.default.isEmpty(this.props.lambda.lambdaAliases)) {
|
|
160
159
|
lodash_1.default.forEach(this.props.lambda.lambdaAliases, (alias, index) => {
|
|
161
160
|
new aws_iam_1.Policy(this, `${this.id}-alias-user-policy`, {
|
|
162
|
-
policyName: `${this.id}
|
|
161
|
+
policyName: this.resourceNameFormatter(`${this.id}--alias-policy-${index}`),
|
|
163
162
|
statements: [
|
|
164
163
|
new aws_iam_1.PolicyStatement({
|
|
165
164
|
actions: ['lambda:InvokeFunction'],
|
|
@@ -181,7 +180,7 @@ class LambdaWithIamAccess extends common_1.CommonConstruct {
|
|
|
181
180
|
* @summary Method to create iam secret for the lambda function
|
|
182
181
|
*/
|
|
183
182
|
createIamSecretForLambdaFunction() {
|
|
184
|
-
this.lambdaUserAccessSecret =
|
|
183
|
+
this.lambdaUserAccessSecret = this.secretsManager.createSecret(`${this.id}-lambda-user-secret-${this.props.stage}`, this, this.props.lambdaSecret);
|
|
185
184
|
const cfnSecret = this.lambdaUserAccessSecret.node.defaultChild;
|
|
186
185
|
cfnSecret.generateSecretString = undefined;
|
|
187
186
|
cfnSecret.secretString = `{ "ACCESS_KEY_ID": "${this.lambdaUserAccessKey.ref}", "ACCESS_KEY_SECRET": "${this.lambdaUserAccessKey.attrSecretAccessKey}" }`;
|
|
@@ -220,13 +220,11 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
220
220
|
enableECSManagedTags: true,
|
|
221
221
|
healthCheckGracePeriod: aws_cdk_lib_1.Duration.seconds(60),
|
|
222
222
|
listenerPort: this.props.siteTask.listenerPort,
|
|
223
|
-
loadBalancerName: this.props.siteTask.loadBalancerName
|
|
224
|
-
? `${this.props.siteTask.loadBalancerName}-${this.props.stage}`
|
|
225
|
-
: `${this.id}-${this.props.stage}`,
|
|
223
|
+
loadBalancerName: this.resourceNameFormatter(this.props.siteTask.loadBalancerName ?? this.id),
|
|
226
224
|
maxHealthyPercent: this.props.siteTask.maxHealthyPercent,
|
|
227
225
|
memoryLimitMiB: this.props.siteTask.memoryLimitMiB,
|
|
228
226
|
minHealthyPercent: this.props.siteTask.minHealthyPercent,
|
|
229
|
-
serviceName:
|
|
227
|
+
serviceName: this.resourceNameFormatter(this.props.siteTask.serviceName ?? this.id),
|
|
230
228
|
taskDefinition: this.props.siteTask.taskDefinition,
|
|
231
229
|
taskImageOptions: {
|
|
232
230
|
containerPort: this.props.siteTask.taskImageOptions?.containerPort,
|
|
@@ -306,14 +304,14 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
306
304
|
transitEncryption: this.props.siteFileSystem.transitEncryption,
|
|
307
305
|
transitEncryptionPort: this.props.siteFileSystem.transitEncryptionPort,
|
|
308
306
|
},
|
|
309
|
-
name:
|
|
307
|
+
name: this.resourceNameFormatter(this.props.siteFileSystem?.fileSystemName ?? this.id),
|
|
310
308
|
});
|
|
311
309
|
if (this.props.siteTask.mountPoints && !lodash_1.default.isEmpty(this.props.siteTask.mountPoints)) {
|
|
312
310
|
lodash_1.default.forEach(this.props.siteTask.mountPoints, mountPoint => {
|
|
313
311
|
this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
|
|
314
312
|
containerPath: mountPoint.containerPath,
|
|
315
313
|
readOnly: mountPoint.readOnly,
|
|
316
|
-
sourceVolume:
|
|
314
|
+
sourceVolume: this.resourceNameFormatter(this.props.siteFileSystem?.fileSystemName ?? this.id),
|
|
317
315
|
});
|
|
318
316
|
});
|
|
319
317
|
}
|
|
@@ -330,8 +328,10 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
330
328
|
this.siteLogBucket = this.s3Manager.createS3Bucket(`${this.id}-site-logs`, this, this.props.siteLogBucket);
|
|
331
329
|
}
|
|
332
330
|
createSiteCachePolicy(id, siteCachePolicy) {
|
|
331
|
+
if (!siteCachePolicy.cachePolicyName)
|
|
332
|
+
throw `SiteCachePolicy cachePolicyName undefined for ${id}`;
|
|
333
333
|
return new aws_cloudfront_1.CachePolicy(this, `${id}`, {
|
|
334
|
-
cachePolicyName:
|
|
334
|
+
cachePolicyName: this.resourceNameFormatter(siteCachePolicy.cachePolicyName),
|
|
335
335
|
comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
336
336
|
cookieBehavior: siteCachePolicy.cookieBehavior,
|
|
337
337
|
enableAcceptEncodingBrotli: siteCachePolicy.enableAcceptEncodingBrotli,
|
|
@@ -353,11 +353,13 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
353
353
|
createSiteOriginRequestPolicy() {
|
|
354
354
|
if (!this.props.siteOriginRequestPolicy)
|
|
355
355
|
return;
|
|
356
|
+
if (!this.props.siteOriginRequestPolicy.originRequestPolicyName)
|
|
357
|
+
throw `SiteOriginRequestPolicy originRequestPolicyName undefined for ${this.id}`;
|
|
356
358
|
this.siteOriginRequestPolicy = new aws_cloudfront_1.OriginRequestPolicy(this, `${this.id}-sorp`, {
|
|
357
359
|
comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
358
360
|
cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
|
|
359
361
|
headerBehavior: this.props.siteOriginRequestPolicy.headerBehavior,
|
|
360
|
-
originRequestPolicyName:
|
|
362
|
+
originRequestPolicyName: this.resourceNameFormatter(this.props.siteOriginRequestPolicy.originRequestPolicyName),
|
|
361
363
|
queryStringBehavior: this.props.siteOriginRequestPolicy.queryStringBehavior,
|
|
362
364
|
});
|
|
363
365
|
lodash_1.default.assign(this.props.siteDistribution.defaultBehavior, {
|
|
@@ -367,10 +369,12 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
367
369
|
createResponseHeaderPolicy(props) {
|
|
368
370
|
if (!props)
|
|
369
371
|
return undefined;
|
|
372
|
+
if (!props.responseHeadersPolicyName)
|
|
373
|
+
throw `SiteResponseHeadersPolicy responseHeadersPolicyName undefined for ${this.id}`;
|
|
370
374
|
return new aws_cloudfront_1.ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
|
|
371
375
|
...props,
|
|
372
376
|
comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
373
|
-
responseHeadersPolicyName:
|
|
377
|
+
responseHeadersPolicyName: this.resourceNameFormatter(props.responseHeadersPolicyName),
|
|
374
378
|
securityHeadersBehavior: {
|
|
375
379
|
...props.securityHeadersBehavior,
|
|
376
380
|
strictTransportSecurity: {
|
|
@@ -136,8 +136,10 @@ class SiteWithLambdaBackend extends common_1.CommonConstruct {
|
|
|
136
136
|
this.siteLogBucket = this.s3Manager.createS3Bucket(`${this.id}-site-logs`, this, this.props.siteLogBucket);
|
|
137
137
|
}
|
|
138
138
|
createSiteCachePolicy(id, siteCachePolicy) {
|
|
139
|
+
if (!siteCachePolicy.cachePolicyName)
|
|
140
|
+
throw `SiteCachePolicy cachePolicyName undefined for ${id}`;
|
|
139
141
|
return new aws_cloudfront_1.CachePolicy(this, `${id}`, {
|
|
140
|
-
cachePolicyName:
|
|
142
|
+
cachePolicyName: this.resourceNameFormatter(siteCachePolicy.cachePolicyName),
|
|
141
143
|
comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
142
144
|
cookieBehavior: siteCachePolicy.cookieBehavior,
|
|
143
145
|
enableAcceptEncodingBrotli: siteCachePolicy.enableAcceptEncodingBrotli,
|
|
@@ -159,11 +161,13 @@ class SiteWithLambdaBackend extends common_1.CommonConstruct {
|
|
|
159
161
|
createSiteOriginRequestPolicy() {
|
|
160
162
|
if (!this.props.siteOriginRequestPolicy)
|
|
161
163
|
return;
|
|
164
|
+
if (!this.props.siteOriginRequestPolicy.originRequestPolicyName)
|
|
165
|
+
throw `SiteOriginRequestPolicy originRequestPolicyName undefined for ${this.id}`;
|
|
162
166
|
this.siteOriginRequestPolicy = new aws_cloudfront_1.OriginRequestPolicy(this, `${this.id}-sorp`, {
|
|
163
167
|
comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
164
168
|
cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
|
|
165
169
|
headerBehavior: this.props.siteOriginRequestPolicy.headerBehavior,
|
|
166
|
-
originRequestPolicyName:
|
|
170
|
+
originRequestPolicyName: this.resourceNameFormatter(this.props.siteOriginRequestPolicy.originRequestPolicyName),
|
|
167
171
|
queryStringBehavior: this.props.siteOriginRequestPolicy.queryStringBehavior,
|
|
168
172
|
});
|
|
169
173
|
lodash_1.default.assign(this.props.siteDistribution.defaultBehavior, {
|
|
@@ -173,10 +177,12 @@ class SiteWithLambdaBackend extends common_1.CommonConstruct {
|
|
|
173
177
|
createResponseHeaderPolicy(props) {
|
|
174
178
|
if (!props)
|
|
175
179
|
return undefined;
|
|
180
|
+
if (!props.responseHeadersPolicyName)
|
|
181
|
+
throw `SiteResponseHeadersPolicy responseHeadersPolicyName undefined for ${this.id}`;
|
|
176
182
|
return new aws_cloudfront_1.ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
|
|
177
183
|
...props,
|
|
178
184
|
comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
179
|
-
responseHeadersPolicyName:
|
|
185
|
+
responseHeadersPolicyName: this.resourceNameFormatter(props.responseHeadersPolicyName),
|
|
180
186
|
securityHeadersBehavior: {
|
|
181
187
|
...props.securityHeadersBehavior,
|
|
182
188
|
strictTransportSecurity: {
|
|
@@ -36,6 +36,8 @@ class ApiManager {
|
|
|
36
36
|
createLambdaRestApi(id, scope, props, lambdaFunction) {
|
|
37
37
|
if (!props)
|
|
38
38
|
throw `Api props undefined for ${id}`;
|
|
39
|
+
if (!props.restApiName)
|
|
40
|
+
throw `Api restApiName undefined for ${id}`;
|
|
39
41
|
const api = new aws_apigateway_1.LambdaRestApi(scope, `${id}`, {
|
|
40
42
|
...props,
|
|
41
43
|
cloudWatchRole: props.cloudWatchRole || false,
|
|
@@ -53,7 +55,7 @@ class ApiManager {
|
|
|
53
55
|
handler: lambdaFunction,
|
|
54
56
|
minCompressionSize: props.minCompressionSizeInBytes ? aws_cdk_lib_1.Size.bytes(props.minCompressionSizeInBytes) : undefined,
|
|
55
57
|
proxy: props.proxy ?? true,
|
|
56
|
-
restApiName:
|
|
58
|
+
restApiName: scope.resourceNameFormatter(props.restApiName, props.resourceNameOptions),
|
|
57
59
|
});
|
|
58
60
|
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
59
61
|
lodash_1.default.forEach(props.tags, tag => {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { LambdaRestApiProps as LambdaRestApigProps } from 'aws-cdk-lib/aws-apigateway';
|
|
1
|
+
import { LambdaRestApiProps as LambdaRestApigProps, RestApiProps } from 'aws-cdk-lib/aws-apigateway';
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common';
|
|
2
3
|
import { TagProps } from '../../types';
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
6
|
export interface LambdaRestApiProps extends LambdaRestApigProps {
|
|
6
7
|
tags?: TagProps[];
|
|
7
8
|
minCompressionSizeInBytes?: number;
|
|
9
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
10
|
+
}
|
|
11
|
+
export interface RestApigProps extends RestApiProps {
|
|
12
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
8
13
|
}
|
|
@@ -50,7 +50,7 @@ class AppConfigManager {
|
|
|
50
50
|
throw `AppConfig props undefined for ${id}`;
|
|
51
51
|
const application = new aws_appconfig_1.CfnApplication(scope, `${id}`, {
|
|
52
52
|
...props.application,
|
|
53
|
-
name:
|
|
53
|
+
name: scope.resourceNameFormatter(props.application.name, props.resourceNameOptions),
|
|
54
54
|
});
|
|
55
55
|
(0, utils_1.createCfnOutput)(`${id}-ApplicationId`, scope, aws_cdk_lib_1.Fn.ref(application.logicalId));
|
|
56
56
|
(0, utils_1.createCfnOutput)(`${id}-ApplicationName`, scope, application.name);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CfnApplicationProps, CfnConfigurationProfileProps, CfnDeploymentProps, CfnDeploymentStrategyProps, CfnEnvironmentProps } from 'aws-cdk-lib/aws-appconfig';
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common';
|
|
2
3
|
/**
|
|
3
4
|
*/
|
|
4
5
|
export interface AppConfigProps {
|
|
@@ -8,4 +9,5 @@ export interface AppConfigProps {
|
|
|
8
9
|
deploymentStrategy: CfnDeploymentStrategyProps;
|
|
9
10
|
environment: CfnEnvironmentProps;
|
|
10
11
|
id: string;
|
|
12
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
11
13
|
}
|
|
@@ -228,6 +228,8 @@ class CloudFrontManager {
|
|
|
228
228
|
createEdgeFunction(id, scope, props, layers, code, role, environment, vpc, securityGroups, accessPoint, mountPath) {
|
|
229
229
|
if (!props)
|
|
230
230
|
throw `EdgeFunction props undefined for ${id}`;
|
|
231
|
+
if (!props.functionName)
|
|
232
|
+
throw `EdgeFunction functionName undefined for ${id}`;
|
|
231
233
|
const edgeFunction = new cf.experimental.EdgeFunction(scope, `${id}`, {
|
|
232
234
|
code: code,
|
|
233
235
|
description: props.description,
|
|
@@ -235,7 +237,7 @@ class CloudFrontManager {
|
|
|
235
237
|
...environment,
|
|
236
238
|
},
|
|
237
239
|
filesystem: accessPoint ? aws_lambda_1.FileSystem.fromEfsAccessPoint(accessPoint, mountPath ?? '/mnt/msg') : undefined,
|
|
238
|
-
functionName:
|
|
240
|
+
functionName: scope.resourceNameFormatter(props.functionName, props.resourceNameOptions),
|
|
239
241
|
handler: props.handler ?? 'index.handler',
|
|
240
242
|
layers: layers,
|
|
241
243
|
logRetention: props.logRetention,
|
|
@@ -286,12 +288,16 @@ class CloudFrontManager {
|
|
|
286
288
|
* @param props
|
|
287
289
|
*/
|
|
288
290
|
createCloudfrontFunction(id, scope, props) {
|
|
291
|
+
if (!props)
|
|
292
|
+
throw `CloudFront Function props undefined for ${id}`;
|
|
293
|
+
if (!props.functionName)
|
|
294
|
+
throw `CloudFront Function functionName undefined for ${id}`;
|
|
289
295
|
const cloudfrontFunction = new aws_cloudfront_1.Function(scope, `${id}`, {
|
|
290
296
|
code: aws_cloudfront_1.FunctionCode.fromFile({
|
|
291
297
|
filePath: props.functionFilePath,
|
|
292
298
|
}),
|
|
293
299
|
comment: props.comment,
|
|
294
|
-
functionName:
|
|
300
|
+
functionName: scope.resourceNameFormatter(props.functionName, props.resourceNameOptions),
|
|
295
301
|
});
|
|
296
302
|
(0, utils_1.createCfnOutput)(`${id}-functionArn`, scope, cloudfrontFunction.functionArn);
|
|
297
303
|
(0, utils_1.createCfnOutput)(`${id}-functionName`, scope, cloudfrontFunction.functionName);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DistributionProps as CfDistributionProps, CloudFrontWebDistributionProps, FunctionProps } from 'aws-cdk-lib/aws-cloudfront';
|
|
2
|
+
import { ResourceNameFormatterProps } from '../../common';
|
|
2
3
|
import { TagProps } from '../../types';
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
@@ -15,4 +16,5 @@ export interface DistributionProps extends CfDistributionProps {
|
|
|
15
16
|
export interface CloudfrontFunctionProps extends FunctionProps {
|
|
16
17
|
eventType: string;
|
|
17
18
|
functionFilePath: string;
|
|
19
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
18
20
|
}
|
|
@@ -40,6 +40,8 @@ class CloudTrailManager {
|
|
|
40
40
|
createCloudTrail(id, scope, props, logGroup, dataBucket, logBucket, logBucketPolicy) {
|
|
41
41
|
if (!props)
|
|
42
42
|
throw `CloudTrail props undefined for ${id}`;
|
|
43
|
+
if (!props.trailName)
|
|
44
|
+
throw `CloudTrail trailName undefined for ${id}`;
|
|
43
45
|
const role = scope.iamManager.createRoleForCloudTrail(`${id}Role`, scope, logGroup);
|
|
44
46
|
const cloudTrail = new aws_cloudtrail_1.CfnTrail(scope, `${id}`, {
|
|
45
47
|
...props,
|
|
@@ -60,7 +62,7 @@ class CloudTrailManager {
|
|
|
60
62
|
s3BucketName: logBucket.bucketName,
|
|
61
63
|
s3KeyPrefix: `logs-${props.trailName}`,
|
|
62
64
|
tags: [{ key: 'service', value: scope.props.name }],
|
|
63
|
-
trailName:
|
|
65
|
+
trailName: scope.resourceNameFormatter(props.trailName, props.resourceNameOptions),
|
|
64
66
|
});
|
|
65
67
|
cloudTrail.addDependency(logBucketPolicy);
|
|
66
68
|
cloudTrail.addDependency(logGroup);
|
|
@@ -56,9 +56,11 @@ class DynamodbManager {
|
|
|
56
56
|
createTableV2(id, scope, props) {
|
|
57
57
|
if (!props)
|
|
58
58
|
throw `Table props undefined for ${id}`;
|
|
59
|
+
if (!props.tableName)
|
|
60
|
+
throw `Table tableName undefined for ${id}`;
|
|
59
61
|
const table = new aws_dynamodb_1.TableV2(scope, `${id}`, {
|
|
60
62
|
...props,
|
|
61
|
-
tableName:
|
|
63
|
+
tableName: scope.resourceNameFormatter(props.tableName, props.resourceNameOptions),
|
|
62
64
|
});
|
|
63
65
|
(0, utils_1.createCfnOutput)(`${id}-tableName`, scope, table.tableName);
|
|
64
66
|
(0, utils_1.createCfnOutput)(`${id}-tableArn`, scope, table.tableArn);
|
|
@@ -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
|
*/
|
|
@@ -6,4 +7,5 @@ export interface TableProps extends dynamodb.TableProps {
|
|
|
6
7
|
tags?: TagProps[];
|
|
7
8
|
}
|
|
8
9
|
export interface TablePropsV2 extends dynamodb.TablePropsV2 {
|
|
10
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
9
11
|
}
|
|
@@ -113,6 +113,10 @@ class EcsManager {
|
|
|
113
113
|
createLoadBalancedFargateService(id, scope, props, cluster, logGroup) {
|
|
114
114
|
if (!props)
|
|
115
115
|
throw `Ecs Load balanced Fargate Service props undefined for ${id}`;
|
|
116
|
+
if (!props.loadBalancerName)
|
|
117
|
+
throw `Ecs loadBalancerName undefined for ${id}`;
|
|
118
|
+
if (!props.serviceName)
|
|
119
|
+
throw `Ecs serviceName undefined for ${id}`;
|
|
116
120
|
if (!props.taskImageOptions)
|
|
117
121
|
throw `TaskImageOptions for Ecs Load balanced Fargate Service props undefined for ${id}`;
|
|
118
122
|
const fargateService = new aws_ecs_patterns_1.ApplicationLoadBalancedFargateService(scope, `${id}-ecs-service`, {
|
|
@@ -121,12 +125,12 @@ class EcsManager {
|
|
|
121
125
|
cluster,
|
|
122
126
|
enableECSManagedTags: true,
|
|
123
127
|
healthCheckGracePeriod: props.healthCheckGracePeriod ?? aws_cdk_lib_1.Duration.seconds(60),
|
|
124
|
-
loadBalancerName:
|
|
128
|
+
loadBalancerName: scope.resourceNameFormatter(props.loadBalancerName, props.resourceNameOptions),
|
|
125
129
|
runtimePlatform: {
|
|
126
130
|
cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? aws_ecs_1.CpuArchitecture.X86_64,
|
|
127
131
|
operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? aws_ecs_1.OperatingSystemFamily.LINUX,
|
|
128
132
|
},
|
|
129
|
-
serviceName:
|
|
133
|
+
serviceName: scope.resourceNameFormatter(props.serviceName, props.resourceNameOptions),
|
|
130
134
|
taskImageOptions: {
|
|
131
135
|
...props.taskImageOptions,
|
|
132
136
|
enableLogging: props.taskImageOptions?.enableLogging ?? true,
|
|
@@ -2,6 +2,7 @@ import { ScalingSchedule } from 'aws-cdk-lib/aws-applicationautoscaling';
|
|
|
2
2
|
import { AwsLogDriverProps, ClusterProps, HealthCheck as FargateHealthCheck, MountPoint, TaskDefinitionProps } from 'aws-cdk-lib/aws-ecs';
|
|
3
3
|
import { ApplicationLoadBalancedFargateServiceProps } from 'aws-cdk-lib/aws-ecs-patterns';
|
|
4
4
|
import { HealthCheck as ElbHealthCheck } from 'aws-cdk-lib/aws-elasticloadbalancingv2';
|
|
5
|
+
import { ResourceNameFormatterProps } from '../../common';
|
|
5
6
|
import { TagProps } from '../../types';
|
|
6
7
|
/**
|
|
7
8
|
*/
|
|
@@ -42,4 +43,5 @@ export interface EcsApplicationLoadBalancedFargateServiceProps extends Applicati
|
|
|
42
43
|
logging?: AwsLogDriverProps;
|
|
43
44
|
mountPoints?: MountPoint[];
|
|
44
45
|
siteScaling?: EcsScalingProps;
|
|
46
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
45
47
|
}
|
|
@@ -47,10 +47,12 @@ class EfsManager {
|
|
|
47
47
|
createFileSystem(id, scope, props, vpc, accessPointOptions, securityGroup, vpcSubnets) {
|
|
48
48
|
if (!props)
|
|
49
49
|
throw `EFS props undefined for ${id}`;
|
|
50
|
+
if (!props.fileSystemName)
|
|
51
|
+
throw `EFS fileSystemName undefined for ${id}`;
|
|
50
52
|
const fileSystemId = props.provisionNewOnDeployment ? `${id}-${new Date().getMilliseconds()}` : `${id}`;
|
|
51
53
|
const fileSystem = new aws_efs_1.FileSystem(scope, `${fileSystemId}`, {
|
|
52
54
|
...props,
|
|
53
|
-
fileSystemName: props.fileSystemName
|
|
55
|
+
fileSystemName: scope.resourceNameFormatter(props.fileSystemName, props.resourceNameOptions),
|
|
54
56
|
lifecyclePolicy: props.lifecyclePolicy ?? aws_efs_1.LifecyclePolicy.AFTER_7_DAYS,
|
|
55
57
|
outOfInfrequentAccessPolicy: props.outOfInfrequentAccessPolicy ?? aws_efs_1.OutOfInfrequentAccessPolicy.AFTER_1_ACCESS,
|
|
56
58
|
performanceMode: props.performanceMode ?? aws_efs_1.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
|
export interface EfsFileSystemProps extends FileSystemProps {
|
|
@@ -8,6 +9,7 @@ export interface EfsFileSystemProps extends FileSystemProps {
|
|
|
8
9
|
rootDirectory?: string;
|
|
9
10
|
transitEncryption?: string;
|
|
10
11
|
transitEncryptionPort?: number;
|
|
12
|
+
resourceNameOptions?: ResourceNameFormatterProps;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
*/
|
|
@@ -32,6 +32,8 @@ class EksManager {
|
|
|
32
32
|
createEksDeployment(id, scope, props, image, vpc) {
|
|
33
33
|
if (!props)
|
|
34
34
|
throw `EksCluster props undefined for ${id}`;
|
|
35
|
+
if (!props.clusterName)
|
|
36
|
+
throw `EksCluster clusterName undefined for ${id}`;
|
|
35
37
|
const appLabel = { app: `${id}`.toLowerCase() };
|
|
36
38
|
const deployment = {
|
|
37
39
|
apiVersion: 'apps/v1',
|
|
@@ -71,7 +73,7 @@ class EksManager {
|
|
|
71
73
|
},
|
|
72
74
|
};
|
|
73
75
|
const cluster = new aws_eks_1.Cluster(scope, `${id}Cluster`, {
|
|
74
|
-
clusterName:
|
|
76
|
+
clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
|
|
75
77
|
defaultCapacity: props.appCapacity,
|
|
76
78
|
defaultCapacityInstance: aws_ec2_1.InstanceType.of(aws_ec2_1.InstanceClass.T3, aws_ec2_1.InstanceSize.LARGE),
|
|
77
79
|
version: aws_eks_1.KubernetesVersion.V1_27,
|