Skip to content

Commit

Permalink
feat(aws): added ability to skip naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
despock committed Sep 3, 2024
1 parent dab78c0 commit 6a5c237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib/aws/common/resource-name-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ export class ResourceNameFormatter extends Construct {
*/
public format(resourceName: string, options?: ResourceNameFormatterProps) {
const resourceNameElements = []
resourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined)
resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
if (!options?.exclude) {
resourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined)
resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
}
resourceNameElements.push(resourceName)
resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
resourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined)
if (!options?.exclude) {
resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
resourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined)
}
resourceNameElements.push(this.props.stage)
return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-')
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/aws/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface CommonStackProps extends BaseProps, StackProps {
}

export interface ResourceNameFormatterProps {
exclude?: boolean
globalPrefix?: boolean
globalSuffix?: boolean
prefix?: string
Expand Down

0 comments on commit 6a5c237

Please sign in to comment.