@gradientedge/cdk-utils 8.36.0 → 8.38.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/common/stack.d.ts +1 -0
- package/dist/src/lib/common/stack.js +1 -0
- package/dist/src/lib/manager/aws/ecs-manager.js +2 -0
- package/dist/src/lib/manager/aws/s3-manager.d.ts +14 -7
- package/dist/src/lib/manager/aws/s3-manager.js +24 -14
- package/dist/src/lib/types/aws/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/lib/common/stack.ts +1 -0
- package/src/lib/manager/aws/ecs-manager.ts +2 -0
- package/src/lib/manager/aws/s3-manager.ts +25 -14
- package/src/lib/types/aws/index.ts +4 -1
|
@@ -76,6 +76,7 @@ class CommonStack extends cdk.Stack {
|
|
|
76
76
|
extraContexts: this.node.tryGetContext('extraContexts'),
|
|
77
77
|
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
78
78
|
logRetention: this.node.tryGetContext('logRetention'),
|
|
79
|
+
excludeDomainNameForBuckets: this.node.tryGetContext('excludeDomainNameForBuckets'),
|
|
79
80
|
nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
|
|
80
81
|
};
|
|
81
82
|
}
|
|
@@ -116,6 +116,8 @@ class EcsManager {
|
|
|
116
116
|
logging: ecs.LogDriver.awsLogs({
|
|
117
117
|
logGroup: logGroup,
|
|
118
118
|
streamPrefix: `${id}`,
|
|
119
|
+
multilinePattern: props.logging?.multilinePattern,
|
|
120
|
+
logRetention: props.logging?.logRetention,
|
|
119
121
|
}),
|
|
120
122
|
memoryLimitMiB: props.memoryMiB ? parseInt(props.memoryMiB) : undefined,
|
|
121
123
|
privileged: false,
|
|
@@ -32,19 +32,26 @@ export declare class S3Manager {
|
|
|
32
32
|
*/
|
|
33
33
|
protected determineBucketLifecycleRules(props: types.S3BucketProps): types.LifecycleRule[] | undefined;
|
|
34
34
|
/**
|
|
35
|
-
* @summary Method to determine the bucket name
|
|
35
|
+
* @summary Method to determine the bucket name using account and region
|
|
36
36
|
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
37
|
-
* @param {
|
|
38
|
-
* @
|
|
37
|
+
* @param {string} bucketName the bucket name
|
|
38
|
+
* @protected
|
|
39
39
|
*/
|
|
40
|
-
protected static
|
|
40
|
+
protected static determineBucketNameByAccountAndRegion(scope: common.CommonConstruct, bucketName: string): string;
|
|
41
41
|
/**
|
|
42
|
-
* @summary Method to determine the
|
|
42
|
+
* @summary Method to determine the bucket name using domain name
|
|
43
43
|
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {string} bucketName the bucket name
|
|
45
|
+
* @protected
|
|
46
|
+
*/
|
|
47
|
+
protected static determineBucketNameByDomainName(scope: common.CommonConstruct, bucketName: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* @summary Method to determine the bucket name
|
|
50
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
51
|
+
* @param {string} bucketName the bucket name
|
|
45
52
|
* @private
|
|
46
53
|
*/
|
|
47
|
-
protected static
|
|
54
|
+
protected static determineBucketName(scope: common.CommonConstruct, bucketName: string): string;
|
|
48
55
|
/**
|
|
49
56
|
* @summary Method to create a s3 bucket
|
|
50
57
|
* @param {string} id scoped id of the resource
|
|
@@ -79,26 +79,36 @@ class S3Manager {
|
|
|
79
79
|
return bucketLifecycleRules;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* @summary Method to determine the bucket name
|
|
82
|
+
* @summary Method to determine the bucket name using account and region
|
|
83
83
|
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
84
|
-
* @param {
|
|
85
|
-
* @
|
|
84
|
+
* @param {string} bucketName the bucket name
|
|
85
|
+
* @protected
|
|
86
|
+
*/
|
|
87
|
+
static determineBucketNameByAccountAndRegion(scope, bucketName) {
|
|
88
|
+
return `${bucketName}-${cdk.Stack.of(scope).account}-${scope.props.region}-${scope.props.stage}`;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @summary Method to determine the bucket name using domain name
|
|
92
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
93
|
+
* @param {string} bucketName the bucket name
|
|
94
|
+
* @protected
|
|
86
95
|
*/
|
|
87
|
-
static
|
|
96
|
+
static determineBucketNameByDomainName(scope, bucketName) {
|
|
88
97
|
return scope.isProductionStage()
|
|
89
|
-
? `${
|
|
90
|
-
: `${
|
|
98
|
+
? `${bucketName}.${scope.fullyQualifiedDomainName}`
|
|
99
|
+
: `${bucketName}-${scope.props.stage}.${scope.fullyQualifiedDomainName}`;
|
|
91
100
|
}
|
|
92
101
|
/**
|
|
93
|
-
* @summary Method to determine the
|
|
102
|
+
* @summary Method to determine the bucket name
|
|
94
103
|
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
95
|
-
* @param {
|
|
104
|
+
* @param {string} bucketName the bucket name
|
|
96
105
|
* @private
|
|
97
106
|
*/
|
|
98
|
-
static
|
|
99
|
-
|
|
100
|
-
?
|
|
101
|
-
:
|
|
107
|
+
static determineBucketName(scope, bucketName) {
|
|
108
|
+
const sanitisedBucketName = scope.props.excludeDomainNameForBuckets
|
|
109
|
+
? S3Manager.determineBucketNameByAccountAndRegion(scope, bucketName)
|
|
110
|
+
: S3Manager.determineBucketNameByDomainName(scope, bucketName);
|
|
111
|
+
return sanitisedBucketName;
|
|
102
112
|
}
|
|
103
113
|
/**
|
|
104
114
|
* @summary Method to create a s3 bucket
|
|
@@ -110,14 +120,14 @@ class S3Manager {
|
|
|
110
120
|
if (!props)
|
|
111
121
|
throw `S3 props undefined for ${id}`;
|
|
112
122
|
let bucket;
|
|
113
|
-
const bucketName = S3Manager.determineBucketName(scope, props);
|
|
123
|
+
const bucketName = S3Manager.determineBucketName(scope, props.bucketName);
|
|
114
124
|
if (props.existingBucket && props.bucketName) {
|
|
115
125
|
bucket = s3.Bucket.fromBucketName(scope, `${id}`, bucketName);
|
|
116
126
|
}
|
|
117
127
|
else {
|
|
118
128
|
let logBucket;
|
|
119
129
|
if (props.logBucketName) {
|
|
120
|
-
const logBucketName = S3Manager.
|
|
130
|
+
const logBucketName = S3Manager.determineBucketName(scope, props.logBucketName);
|
|
121
131
|
logBucket = s3.Bucket.fromBucketName(scope, `${id}-logs`, logBucketName);
|
|
122
132
|
}
|
|
123
133
|
bucket = new s3.Bucket(scope, `${id}-bucket`, {
|
|
@@ -53,6 +53,7 @@ export interface CommonStackProps extends cdk.StackProps {
|
|
|
53
53
|
stageContextPath?: string;
|
|
54
54
|
skipStageForARecords: boolean;
|
|
55
55
|
logRetention?: logs.RetentionDays;
|
|
56
|
+
excludeDomainNameForBuckets?: boolean;
|
|
56
57
|
nodejsRuntime?: lambda.Runtime;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
@@ -599,6 +600,7 @@ export interface EcsClusterProps extends ecs.ClusterProps {
|
|
|
599
600
|
* @subcategory Properties
|
|
600
601
|
*/
|
|
601
602
|
export interface EcsTaskProps extends ecs.TaskDefinitionProps {
|
|
603
|
+
logging?: ecs.AwsLogDriverProps;
|
|
602
604
|
}
|
|
603
605
|
/**
|
|
604
606
|
* @category cdk-utils.ecs-manager
|
package/package.json
CHANGED
package/src/lib/common/stack.ts
CHANGED
|
@@ -60,6 +60,7 @@ export class CommonStack extends cdk.Stack {
|
|
|
60
60
|
extraContexts: this.node.tryGetContext('extraContexts'),
|
|
61
61
|
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
62
62
|
logRetention: this.node.tryGetContext('logRetention'),
|
|
63
|
+
excludeDomainNameForBuckets: this.node.tryGetContext('excludeDomainNameForBuckets'),
|
|
63
64
|
nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
|
|
64
65
|
}
|
|
65
66
|
}
|
|
@@ -111,6 +111,8 @@ export class EcsManager {
|
|
|
111
111
|
logging: ecs.LogDriver.awsLogs({
|
|
112
112
|
logGroup: logGroup,
|
|
113
113
|
streamPrefix: `${id}`,
|
|
114
|
+
multilinePattern: props.logging?.multilinePattern,
|
|
115
|
+
logRetention: props.logging?.logRetention,
|
|
114
116
|
}),
|
|
115
117
|
memoryLimitMiB: props.memoryMiB ? parseInt(props.memoryMiB) : undefined,
|
|
116
118
|
privileged: false,
|
|
@@ -59,27 +59,38 @@ export class S3Manager {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* @summary Method to determine the bucket name
|
|
62
|
+
* @summary Method to determine the bucket name using account and region
|
|
63
63
|
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
64
|
-
* @param {
|
|
65
|
-
* @
|
|
64
|
+
* @param {string} bucketName the bucket name
|
|
65
|
+
* @protected
|
|
66
66
|
*/
|
|
67
|
-
protected static
|
|
67
|
+
protected static determineBucketNameByAccountAndRegion(scope: common.CommonConstruct, bucketName: string) {
|
|
68
|
+
return `${bucketName}-${cdk.Stack.of(scope).account}-${scope.props.region}-${scope.props.stage}`
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @summary Method to determine the bucket name using domain name
|
|
73
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
74
|
+
* @param {string} bucketName the bucket name
|
|
75
|
+
* @protected
|
|
76
|
+
*/
|
|
77
|
+
protected static determineBucketNameByDomainName(scope: common.CommonConstruct, bucketName: string) {
|
|
68
78
|
return scope.isProductionStage()
|
|
69
|
-
? `${
|
|
70
|
-
: `${
|
|
79
|
+
? `${bucketName}.${scope.fullyQualifiedDomainName}`
|
|
80
|
+
: `${bucketName}-${scope.props.stage}.${scope.fullyQualifiedDomainName}`
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
/**
|
|
74
|
-
* @summary Method to determine the
|
|
84
|
+
* @summary Method to determine the bucket name
|
|
75
85
|
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
76
|
-
* @param {
|
|
86
|
+
* @param {string} bucketName the bucket name
|
|
77
87
|
* @private
|
|
78
88
|
*/
|
|
79
|
-
protected static
|
|
80
|
-
|
|
81
|
-
?
|
|
82
|
-
:
|
|
89
|
+
protected static determineBucketName(scope: common.CommonConstruct, bucketName: string) {
|
|
90
|
+
const sanitisedBucketName = scope.props.excludeDomainNameForBuckets
|
|
91
|
+
? S3Manager.determineBucketNameByAccountAndRegion(scope, bucketName)
|
|
92
|
+
: S3Manager.determineBucketNameByDomainName(scope, bucketName)
|
|
93
|
+
return sanitisedBucketName
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
/**
|
|
@@ -93,14 +104,14 @@ export class S3Manager {
|
|
|
93
104
|
|
|
94
105
|
let bucket: s3.IBucket
|
|
95
106
|
|
|
96
|
-
const bucketName = S3Manager.determineBucketName(scope, props)
|
|
107
|
+
const bucketName = S3Manager.determineBucketName(scope, props.bucketName)
|
|
97
108
|
|
|
98
109
|
if (props.existingBucket && props.bucketName) {
|
|
99
110
|
bucket = s3.Bucket.fromBucketName(scope, `${id}`, bucketName)
|
|
100
111
|
} else {
|
|
101
112
|
let logBucket
|
|
102
113
|
if (props.logBucketName) {
|
|
103
|
-
const logBucketName = S3Manager.
|
|
114
|
+
const logBucketName = S3Manager.determineBucketName(scope, props.logBucketName)
|
|
104
115
|
logBucket = s3.Bucket.fromBucketName(scope, `${id}-logs`, logBucketName)
|
|
105
116
|
}
|
|
106
117
|
|
|
@@ -55,6 +55,7 @@ export interface CommonStackProps extends cdk.StackProps {
|
|
|
55
55
|
stageContextPath?: string
|
|
56
56
|
skipStageForARecords: boolean
|
|
57
57
|
logRetention?: logs.RetentionDays
|
|
58
|
+
excludeDomainNameForBuckets?: boolean
|
|
58
59
|
nodejsRuntime?: lambda.Runtime
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -634,7 +635,9 @@ export interface EcsClusterProps extends ecs.ClusterProps {}
|
|
|
634
635
|
* @category cdk-utils.ecs-manager
|
|
635
636
|
* @subcategory Properties
|
|
636
637
|
*/
|
|
637
|
-
export interface EcsTaskProps extends ecs.TaskDefinitionProps {
|
|
638
|
+
export interface EcsTaskProps extends ecs.TaskDefinitionProps {
|
|
639
|
+
logging?: ecs.AwsLogDriverProps
|
|
640
|
+
}
|
|
638
641
|
|
|
639
642
|
/**
|
|
640
643
|
* @category cdk-utils.ecs-manager
|