|
1 | | -import {CloudFormationClient, ListExportsCommand, DescribeStacksCommand} from "@aws-sdk/client-cloudformation" |
| 1 | +import {CloudFormationClient, DescribeStacksCommand} from "@aws-sdk/client-cloudformation" |
2 | 2 | import {S3Client, HeadObjectCommand} from "@aws-sdk/client-s3" |
3 | 3 |
|
4 | 4 | export function getConfigFromEnvVar(varName: string, prefix: string = "CDK_CONFIG_"): string { |
@@ -32,39 +32,6 @@ export async function getTrustStoreVersion(trustStoreFile: string, region: strin |
32 | 32 | return headObjectResponse.VersionId! |
33 | 33 | } |
34 | 34 |
|
35 | | -export async function getCloudFormationExports(region: string = "eu-west-2"): Promise<Record<string, string>> { |
36 | | - const cfnClient = new CloudFormationClient({region}) |
37 | | - const listExportsCommand = new ListExportsCommand({}) |
38 | | - const exports: Record<string, string> = {} |
39 | | - let nextToken: string | undefined = undefined |
40 | | - |
41 | | - do { |
42 | | - const response = await cfnClient.send(listExportsCommand) |
43 | | - response.Exports?.forEach((exp) => { |
44 | | - if (exp.Name && exp.Value) { |
45 | | - exports[exp.Name] = exp.Value |
46 | | - } |
47 | | - }) |
48 | | - nextToken = response.NextToken |
49 | | - listExportsCommand.input.NextToken = nextToken |
50 | | - } while (nextToken) |
51 | | - |
52 | | - return exports |
53 | | -} |
54 | | - |
55 | | -export function getCFConfigValue(exports: Record<string, string>, exportName: string): string { |
56 | | - const value = exports[exportName] |
57 | | - if (!value) { |
58 | | - throw new Error(`CloudFormation export ${exportName} not found`) |
59 | | - } |
60 | | - return value |
61 | | -} |
62 | | - |
63 | | -export function getBooleanCFConfigValue(exports: Record<string, string>, exportName: string): boolean { |
64 | | - const value = getCFConfigValue(exports, exportName) |
65 | | - return value.toLowerCase() === "true" |
66 | | -} |
67 | | - |
68 | 35 | export function calculateVersionedStackName(baseStackName: string, version: string): string { |
69 | 36 | return `${baseStackName}-${version.replaceAll(".", "-")}` |
70 | 37 | } |
0 commit comments