@@ -102,10 +102,10 @@ async function run() {
102
102
if ( waitForMinutes > MAX_WAIT_MINUTES ) {
103
103
waitForMinutes = MAX_WAIT_MINUTES ;
104
104
}
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' , {
107
107
required : false ,
108
- } ) ;
108
+ } ) || '' ;
109
109
const launchType = core . getInput ( 'launch-type' , { required : false } ) ;
110
110
const capacityProviderStrategyString = core . getInput ( 'capacity-provider-strategy' , { required : false } ) || '' ;
111
111
const assignPublicIp = core . getInput ( 'assign-public-ip' , {
@@ -156,23 +156,43 @@ async function run() {
156
156
startedBy : startedBy ,
157
157
} ;
158
158
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
+
159
177
if ( launchType === 'FARGATE' ) {
160
178
runTaskRequest . launchType = launchType ;
179
+ // FARGATE launch type requires awsvpcConfiguration.
161
180
runTaskRequest . networkConfiguration = {
162
- awsvpcConfiguration : {
163
- subnets : subnets . split ( ',' ) ,
164
- securityGroups : securityGroups . split ( ',' ) ,
165
- assignPublicIp,
166
- } ,
167
- } ;
181
+ awsvpcConfiguration : vpcConfiguration ,
182
+ }
168
183
}
169
184
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.
172
186
if ( capacityProviderStrategyString !== "" ) {
173
187
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
+ }
176
196
} catch ( error ) {
177
197
core . setFailed ( "Failed to parse capacity provider strategy definition: " + error . message ) ;
178
198
core . debug ( "Parameter value:" ) ;
0 commit comments