Skip to content

Commit 90f0c58

Browse files
committed
Unset Launch Type if Capacity Provider is Set
1 parent 915d106 commit 90f0c58

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

Diff for: index.js

+33-13
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ async function run() {
102102
if (waitForMinutes > MAX_WAIT_MINUTES) {
103103
waitForMinutes = MAX_WAIT_MINUTES;
104104
}
105-
const subnets = core.getInput('subnets', { required: false });
106-
const securityGroups = core.getInput('security-groups', {
105+
const subnetsString = core.getInput('subnets', { required: false }) || '';
106+
const securityGroupsString = core.getInput('security-groups', {
107107
required: false,
108-
});
108+
}) || '';
109109
const launchType = core.getInput('launch-type', { required: false });
110110
const capacityProviderStrategyString = core.getInput('capacity-provider-strategy', { required: false }) || '';
111111
const assignPublicIp = core.getInput('assign-public-ip', {
@@ -156,23 +156,43 @@ async function run() {
156156
startedBy: startedBy,
157157
};
158158

159+
// Configure Networking Options.
160+
let subnets = undefined;
161+
if (subnetsString !== '') {
162+
subnets = subnetsString.split(',');
163+
}
164+
165+
let securityGroups = undefined;
166+
if (securityGroupsString !== '') {
167+
securityGroups = securityGroupsString.split(',');
168+
}
169+
170+
// Will only be assigned to FARGATE launch type, or when a capacity provider is set.
171+
const vpcConfiguration = {
172+
subnets: subnets,
173+
securityGroups: securityGroups,
174+
assignPublicIp,
175+
}
176+
159177
if (launchType === 'FARGATE') {
160178
runTaskRequest.launchType = launchType;
179+
// FARGATE launch type requires awsvpcConfiguration.
161180
runTaskRequest.networkConfiguration = {
162-
awsvpcConfiguration: {
163-
subnets: subnets.split(','),
164-
securityGroups: securityGroups.split(','),
165-
assignPublicIp,
166-
},
167-
};
181+
awsvpcConfiguration: vpcConfiguration,
182+
}
168183
}
169184

170-
// Only parse capacity provider if value has been set.
171-
let capacityProviderStrategy;
185+
// Only parse capacity provider if value has been set. Overrides launch type.
172186
if (capacityProviderStrategyString !== "") {
173187
try {
174-
capacityProviderStrategy = JSON.parse(capacityProviderStrategyString);
175-
runTaskRequest.capacityProviderStrategy = capacityProviderStrategy;
188+
core.info(`Capacity provider strategy is set. Launch type will be ignored.`);
189+
runTaskRequest.launchType = undefined;
190+
runTaskRequest.capacityProviderStrategy = JSON.parse(capacityProviderStrategyString);
191+
192+
// If capacity provider is provided, then awsvpcConfiguration is required.
193+
runTaskRequest.networkConfiguration = {
194+
awsvpcConfiguration: vpcConfiguration,
195+
}
176196
} catch (error) {
177197
core.setFailed("Failed to parse capacity provider strategy definition: " + error.message);
178198
core.debug("Parameter value:");

0 commit comments

Comments
 (0)