@@ -274,10 +274,10 @@ async function run() {
274
274
if (waitForMinutes > MAX_WAIT_MINUTES) {
275
275
waitForMinutes = MAX_WAIT_MINUTES;
276
276
}
277
- const subnets = core.getInput('subnets', { required: false });
278
- const securityGroups = core.getInput('security-groups', {
277
+ const subnetsString = core.getInput('subnets', { required: false }) || '' ;
278
+ const securityGroupsString = core.getInput('security-groups', {
279
279
required: false,
280
- });
280
+ }) || '' ;
281
281
const launchType = core.getInput('launch-type', { required: false });
282
282
const capacityProviderStrategyString = core.getInput('capacity-provider-strategy', { required: false }) || '';
283
283
const assignPublicIp = core.getInput('assign-public-ip', {
@@ -328,23 +328,43 @@ async function run() {
328
328
startedBy: startedBy,
329
329
};
330
330
331
+ // Configure Networking Options.
332
+ let subnets = undefined;
333
+ if (subnetsString !== '') {
334
+ subnets = subnetsString.split(',');
335
+ }
336
+
337
+ let securityGroups = undefined;
338
+ if (securityGroupsString !== '') {
339
+ securityGroups = securityGroupsString.split(',');
340
+ }
341
+
342
+ // Will only be assigned to FARGATE launch type, or when a capacity provider is set.
343
+ const vpcConfiguration = {
344
+ subnets: subnets,
345
+ securityGroups: securityGroups,
346
+ assignPublicIp,
347
+ }
348
+
331
349
if (launchType === 'FARGATE') {
332
350
runTaskRequest.launchType = launchType;
351
+ // FARGATE launch type requires awsvpcConfiguration.
333
352
runTaskRequest.networkConfiguration = {
334
- awsvpcConfiguration: {
335
- subnets: subnets.split(','),
336
- securityGroups: securityGroups.split(','),
337
- assignPublicIp,
338
- },
339
- };
353
+ awsvpcConfiguration: vpcConfiguration,
354
+ }
340
355
}
341
356
342
- // Only parse capacity provider if value has been set.
343
- let capacityProviderStrategy;
357
+ // Only parse capacity provider if value has been set. Overrides launch type.
344
358
if (capacityProviderStrategyString !== "") {
345
359
try {
346
- capacityProviderStrategy = JSON.parse(capacityProviderStrategyString);
347
- runTaskRequest.capacityProviderStrategy = capacityProviderStrategy;
360
+ core.info(`Capacity provider strategy is set. Launch type will be ignored.`);
361
+ runTaskRequest.launchType = undefined;
362
+ runTaskRequest.capacityProviderStrategy = JSON.parse(capacityProviderStrategyString);
363
+
364
+ // If capacity provider is provided, then awsvpcConfiguration is required.
365
+ runTaskRequest.networkConfiguration = {
366
+ awsvpcConfiguration: vpcConfiguration,
367
+ }
348
368
} catch (error) {
349
369
core.setFailed("Failed to parse capacity provider strategy definition: " + error.message);
350
370
core.debug("Parameter value:");
0 commit comments