-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed getting the service name for SST services
- Loading branch information
Showing
5 changed files
with
14 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import { Stack } from "aws-cdk-lib"; | ||
import { Baselime as Config } from "../config"; | ||
|
||
export function getServiceName(stack: Stack): string { | ||
export function getServiceName(): string { | ||
const s = Config.getServiceName(); | ||
if (s) { | ||
return s; | ||
} | ||
const tags = stack.tags.tagValues(); | ||
|
||
const isSST = Object.keys(tags).some((el) => el.includes("sst")); | ||
const construct = Config.getConstruct(); | ||
const root = construct.node.root as any; | ||
|
||
if (isSST) { | ||
return `${tags['sst:stage']}-${tags['sst:app']}`; | ||
} | ||
const stage = root.stage; | ||
const name = root.name; | ||
|
||
if (stage && name) { | ||
return `${stage}-${name}`; | ||
} | ||
const stack = Stack.of(construct); | ||
return stack.stackName; | ||
} |