@gradientedge/cdk-utils 9.18.0 → 9.20.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/resource-name-formatter.js +8 -4
- package/dist/src/lib/aws/common/types.d.ts +1 -0
- package/dist/src/lib/aws/services/cloudwatch/logs.js +2 -2
- package/package.json +1 -1
- package/src/lib/aws/common/resource-name-formatter.ts +8 -4
- package/src/lib/aws/common/types.ts +1 -0
- package/src/lib/aws/services/cloudwatch/logs.ts +2 -2
|
@@ -16,11 +16,15 @@ class ResourceNameFormatter extends constructs_1.Construct {
|
|
|
16
16
|
*/
|
|
17
17
|
format(resourceName, options) {
|
|
18
18
|
const resourceNameElements = [];
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (!options?.exclude) {
|
|
20
|
+
resourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined);
|
|
21
|
+
resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix);
|
|
22
|
+
}
|
|
21
23
|
resourceNameElements.push(resourceName);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
if (!options?.exclude) {
|
|
25
|
+
resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix);
|
|
26
|
+
resourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined);
|
|
27
|
+
}
|
|
24
28
|
resourceNameElements.push(this.props.stage);
|
|
25
29
|
return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-');
|
|
26
30
|
}
|
|
@@ -88,7 +88,7 @@ class LogManager {
|
|
|
88
88
|
throw `Logs logGroupName undefined for ${id}`;
|
|
89
89
|
const logGroup = new logs.CfnLogGroup(scope, `${id}`, {
|
|
90
90
|
...props,
|
|
91
|
-
logGroupName:
|
|
91
|
+
logGroupName: `${scope.resourceNameFormatter.format(props.logGroupName, scope.props.resourceNameOptions?.logs)}`,
|
|
92
92
|
retentionInDays: props.retention,
|
|
93
93
|
});
|
|
94
94
|
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
@@ -112,7 +112,7 @@ class LogManager {
|
|
|
112
112
|
throw `Logs logGroupName undefined for ${id}`;
|
|
113
113
|
const logGroup = new logs.LogGroup(scope, `${id}`, {
|
|
114
114
|
...props,
|
|
115
|
-
logGroupName:
|
|
115
|
+
logGroupName: `${scope.resourceNameFormatter.format(props.logGroupName, scope.props.resourceNameOptions?.logs)}`,
|
|
116
116
|
removalPolicy: props.removalPolicy ?? cdk.RemovalPolicy.DESTROY,
|
|
117
117
|
retention: props.retention,
|
|
118
118
|
});
|
package/package.json
CHANGED
|
@@ -17,11 +17,15 @@ export class ResourceNameFormatter extends Construct {
|
|
|
17
17
|
*/
|
|
18
18
|
public format(resourceName: string, options?: ResourceNameFormatterProps) {
|
|
19
19
|
const resourceNameElements = []
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (!options?.exclude) {
|
|
21
|
+
resourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined)
|
|
22
|
+
resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
|
|
23
|
+
}
|
|
22
24
|
resourceNameElements.push(resourceName)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
if (!options?.exclude) {
|
|
26
|
+
resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
|
|
27
|
+
resourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined)
|
|
28
|
+
}
|
|
25
29
|
resourceNameElements.push(this.props.stage)
|
|
26
30
|
return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-')
|
|
27
31
|
}
|
|
@@ -64,7 +64,7 @@ export class LogManager {
|
|
|
64
64
|
|
|
65
65
|
const logGroup = new logs.CfnLogGroup(scope, `${id}`, {
|
|
66
66
|
...props,
|
|
67
|
-
logGroupName:
|
|
67
|
+
logGroupName: `${scope.resourceNameFormatter.format(props.logGroupName, scope.props.resourceNameOptions?.logs)}`,
|
|
68
68
|
retentionInDays: props.retention,
|
|
69
69
|
})
|
|
70
70
|
|
|
@@ -91,7 +91,7 @@ export class LogManager {
|
|
|
91
91
|
|
|
92
92
|
const logGroup = new logs.LogGroup(scope, `${id}`, {
|
|
93
93
|
...props,
|
|
94
|
-
logGroupName:
|
|
94
|
+
logGroupName: `${scope.resourceNameFormatter.format(props.logGroupName, scope.props.resourceNameOptions?.logs)}`,
|
|
95
95
|
removalPolicy: props.removalPolicy ?? cdk.RemovalPolicy.DESTROY,
|
|
96
96
|
retention: props.retention,
|
|
97
97
|
})
|