@@ -137,6 +137,15 @@ const CODE_DEPLOY_MAX_WAIT_MINUTES = 360; // 6 hours
137
137
const CODE_DEPLOY_MIN_WAIT_MINUTES = 30;
138
138
const CODE_DEPLOY_WAIT_DEFAULT_DELAY_SEC = 15;
139
139
140
+ // Attributes that are returned by DescribeTaskDefinition, but are not valid RegisterTaskDefinition inputs
141
+ const IGNORED_TASK_DEFINITION_ATTRIBUTES = [
142
+ 'compatibilities',
143
+ 'taskDefinitionArn',
144
+ 'requiresAttributes',
145
+ 'revision',
146
+ 'status'
147
+ ];
148
+
140
149
// Deploy to a service that uses the 'ECS' deployment controller
141
150
async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForService) {
142
151
core.debug('Updating the service');
@@ -191,6 +200,20 @@ function cleanNullKeys(obj) {
191
200
return JSON.parse(JSON.stringify(obj, undefinedOrNullReplacer));
192
201
}
193
202
203
+ function removeIgnoredAttributes(taskDef) {
204
+ for (var attribute of IGNORED_TASK_DEFINITION_ATTRIBUTES) {
205
+ if (taskDef[attribute]) {
206
+ core.warning(`Ignoring property '${attribute}' in the task definition file. ` +
207
+ 'This property is returned by the Amazon ECS DescribeTaskDefinition API and may be shown in the ECS console, ' +
208
+ 'but it is not a valid field when registering a new task definition. ' +
209
+ 'This field can be safely removed from your task definition file.');
210
+ delete taskDef[attribute];
211
+ }
212
+ }
213
+
214
+ return taskDef;
215
+ }
216
+
194
217
// Deploy to a service that uses the 'CODE_DEPLOY' deployment controller
195
218
async function createCodeDeployDeployment(codedeploy, clusterName, service, taskDefArn, waitForService) {
196
219
core.debug('Updating AppSpec file with new task definition ARN');
@@ -292,7 +315,7 @@ async function run() {
292
315
taskDefinitionFile :
293
316
path.join(process.env.GITHUB_WORKSPACE, taskDefinitionFile);
294
317
const fileContents = fs.readFileSync(taskDefPath, 'utf8');
295
- const taskDefContents = cleanNullKeys(yaml.parse(fileContents));
318
+ const taskDefContents = removeIgnoredAttributes( cleanNullKeys(yaml.parse(fileContents) ));
296
319
const registerResponse = await ecs.registerTaskDefinition(taskDefContents).promise();
297
320
const taskDefArn = registerResponse.taskDefinition.taskDefinitionArn;
298
321
core.setOutput('task-definition-arn', taskDefArn);
0 commit comments