0
votes

I'm automating a PR process that need to create stacks through cloudformation. The problem is that, by definition https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-taskdefinition.html the old TaskDefinition revision is deleted to make place for the new/updated TaskDefinition. Is there any way to avoid the replacement and do only an update?

1
Are you asking if there is a way to keep old revisions or is your question if you can do an inplace-update to a task definition?Maurice

1 Answers

0
votes

From the docs:

To update a task definition, create a task definition revision. If the task definition is used in a service, you must update that service to use the updated task definition.

This implies that task definition revisions are immutable and there is no way around creating a new revision.

If you want to retain the old versions of your task definitions, you could try the UpdateReplacementPolicy with a value of Retain. Maybe it's able to keep the old revisions around. For more details check out the CloudFormation docs - UpdateReplacePolicy.

That would look something like this:

AWSTemplateFormatVersion: 2010-09-09
Resources:
  taskdefinition:
    Type: 'AWS::ECS::TaskDefinition'
    UpdateReplacePolicy: Retain
    Properties: {} # Your usual properties here