@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.
@@ -16,11 +16,15 @@ class ResourceNameFormatter extends constructs_1.Construct {
16
16
  */
17
17
  format(resourceName, options) {
18
18
  const resourceNameElements = [];
19
- resourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined);
20
- resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix);
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
- resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix);
23
- resourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined);
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
  }
@@ -22,6 +22,7 @@ export interface CommonStackProps extends BaseProps, StackProps {
22
22
  };
23
23
  }
24
24
  export interface ResourceNameFormatterProps {
25
+ exclude?: boolean;
25
26
  globalPrefix?: boolean;
26
27
  globalSuffix?: boolean;
27
28
  prefix?: string;
@@ -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: `/${scope.resourceNameFormatter.format(props.logGroupName, scope.props.resourceNameOptions?.logs)}`,
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: `/${scope.resourceNameFormatter.format(props.logGroupName, scope.props.resourceNameOptions?.logs)}`,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.18.0",
3
+ "version": "9.20.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -17,11 +17,15 @@ export class ResourceNameFormatter extends Construct {
17
17
  */
18
18
  public format(resourceName: string, options?: ResourceNameFormatterProps) {
19
19
  const resourceNameElements = []
20
- resourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined)
21
- resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
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
- resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
24
- resourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined)
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
  }
@@ -22,6 +22,7 @@ export interface CommonStackProps extends BaseProps, StackProps {
22
22
  }
23
23
 
24
24
  export interface ResourceNameFormatterProps {
25
+ exclude?: boolean
25
26
  globalPrefix?: boolean
26
27
  globalSuffix?: boolean
27
28
  prefix?: string
@@ -64,7 +64,7 @@ export class LogManager {
64
64
 
65
65
  const logGroup = new logs.CfnLogGroup(scope, `${id}`, {
66
66
  ...props,
67
- logGroupName: `/${scope.resourceNameFormatter.format(props.logGroupName, scope.props.resourceNameOptions?.logs)}`,
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: `/${scope.resourceNameFormatter.format(props.logGroupName, scope.props.resourceNameOptions?.logs)}`,
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
  })