milakay
milakay

Reputation: 33

How can I update the launch template version to be set to latest in Terraform?

I am trying to set the the latest version to default in the launch template using Terraform. You can do this quite easily in the AWS console: enter image description here

But I can't seem to find in TF documentation a way to do so.

I am using AWS provider 4.14 in TF.

There is an option to set the latest version but it expects an integer https://registry.terraform.io/providers/hashicorp/aws/4.14.0/docs/resources/launch_template#latest_version

I would like to set that whenever there is an update to the launch template a new version will be created and set to default.

Any suggestions will be appreciated.

Thanks!

Upvotes: 3

Views: 7990

Answers (2)

Lado Golijashvili
Lado Golijashvili

Reputation: 143

You can use update_default_version=true parameter inside resource block, which will make terraform to set latest version as default one.

https://registry.terraform.io/providers/hashicorp/aws/4.14.0/docs/resources/launch_template#update_default_version

here is the doc about that parameter

Upvotes: 2

Marcin
Marcin

Reputation: 238309

You have to use update_default_version:

Whether to update Default Version each update. Conflicts with default_version

Upvotes: 3

Related Questions