-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.js
More file actions
115 lines (108 loc) · 3.33 KB
/
Copy pathparser.js
File metadata and controls
115 lines (108 loc) · 3.33 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
'use strict';
const { get } = require('./util');
const parseTask = (global, name, task) => {
const definition = {
name: task.name || name,
dependsOn: task.dependsOn,
image: task.image,
executionRoleArn: task.executionRoleArn || global.executionRoleArn,
taskRoleArn: task.taskRoleArn || global.taskRoleArn,
vpc: {
subnetIds: get(task, 'vpc.subnetIds', global.vpc.subnetIds),
securityGroupIds: get(
task,
'vpc.securityGroupIds',
global.vpc.securityGroupIds
),
assignPublicIp: get(
task,
'vpc.assignPublicIp',
global.vpc.assignPublicIp
),
},
command: task.command || [],
entryPoint: task.entryPoint || [],
memory: task.instanceConfiguration?.memory || global.memory,
cpu: task.instanceConfiguration?.cpu || global.cpu,
architecture: task.architecture || global.architecture,
environment: {
...global.environment,
...(task.environment || {}),
},
runtimeVariables: task.runtimeVariables || [],
runtimeSecrets: task.runtimeSecrets || [],
tags: { ...global.tags, ...(task.tags || {}) },
cloudFormationResource: {
task: {
...global.cloudFormationResource.task,
...get(task, 'cloudFormationResource.task', {}),
},
container: {
...global.cloudFormationResource.container,
...get(task, 'cloudFormationResource.container', {}),
},
service: {
...global.cloudFormationResource.service,
...get(task, 'cloudFormationResource.service', {}),
},
},
iamRoleStatements: task.iamRoleStatements || []
};
if (task.schedule) {
return {
...definition,
schedule: task.schedule,
};
}
const isStrictMode = get(task, 'service.strict', false);
return {
...definition,
service: {
desiredCount: get(task, 'service.desiredCount', 1),
maximumPercent: get(
task,
'service.maximumPercent',
isStrictMode ? 100 : 200
),
minimumHealthyPercent: get(
task,
'service.minimumHealthyPercent',
isStrictMode ? 0 : 100
),
spot: get(task, 'service.spot', false),
},
};
};
module.exports = config => {
const global = {
clusterName: config.clusterName,
containerInsights: config.containerInsights,
memory: config.memory || '2 GB',
cpu: config.cpu || '1 vCPU',
architecture: config.architecture,
environment: config.environment || {},
executionRoleArn: config.executionRoleArn,
taskRoleArn: config.taskRoleArn,
iamRoleStatements: config.iamRoleStatements || [],
iamManagedPolicies: config.iamManagedPolicies || [],
logGroupName: config.logGroupName,
logRetentionInDays: config.logRetentionInDays,
vpc: {
subnetIds: get(config, 'vpc.subnetIds', []),
securityGroupIds: get(config, 'vpc.securityGroupIds', []),
assignPublicIp: get(config, 'vpc.assignPublicIp', false),
},
services: config.services || {},
cloudFormationResource: {
task: get(config, 'cloudFormationResource.task', {}),
container: get(config, 'cloudFormationResource.container', {}),
service: get(config, 'cloudFormationResource.service', {}),
},
};
return {
...global,
services: Object.entries(config.services).map(([name, service]) =>
parseTask(global, name, service)
),
};
};