generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathhelpers.ts
More file actions
45 lines (40 loc) · 1.65 KB
/
helpers.ts
File metadata and controls
45 lines (40 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { DeployOptions, HotswapProperties } from '..';
import { Deployments, EcsHotswapProperties, HotswapPropertyOverrides, type WorkGraph } from '../../../api/aws-cdk';
export function buildParameterMap(parameters?: Map<string, string | undefined>): { [name: string]: { [name: string]: string | undefined } } {
const parameterMap: {
[name: string]: { [name: string]: string | undefined };
} = {};
parameterMap['*'] = {};
const entries = parameters?.entries() ?? [];
for (const [key, value] of entries) {
const [stack, parameter] = key.split(':', 2) as [string, string | undefined];
if (!parameter) {
parameterMap['*'][stack] = value;
} else {
if (!parameterMap[stack]) {
parameterMap[stack] = {};
}
parameterMap[stack][parameter] = value;
}
}
return parameterMap;
}
/**
* Remove the asset publishing and building from the work graph for assets that are already in place
*/
export async function removePublishedAssets(graph: WorkGraph, deployments: Deployments, options: DeployOptions) {
await graph.removeUnnecessaryAssets(assetNode => deployments.isSingleAssetPublished(assetNode.assetManifest, assetNode.asset, {
stack: assetNode.parentStack,
roleArn: options.roleArn,
stackName: assetNode.parentStack.stackName,
}));
}
/**
* Create the HotswapPropertyOverrides class out of the Interface exposed to users
*/
export function createHotswapPropertyOverrides(hotswapProperties: HotswapProperties): HotswapPropertyOverrides {
return new HotswapPropertyOverrides(new EcsHotswapProperties(
hotswapProperties.ecs.minimumHealthyPercent,
hotswapProperties.ecs.maximumHealthyPercent,
));
}