terraform-aws-modules / terraform-aws-ec2-instance

Terraform module to create AWS EC2 instance(s) resources πŸ‡ΊπŸ‡¦
https://registry.terraform.io/modules/terraform-aws-modules/ec2-instance/aws
Apache License 2.0
758 stars 1.88k forks source link

Avoid replacement on AMI change #300

Closed IgorMilavec closed 2 years ago

IgorMilavec commented 2 years ago

Is your request related to a new offering from AWS?

Is this functionality available in the AWS provider for Terraform? See CHANGELOG.md, too.

Is your request related to a problem? Please describe.

When using Windows AMI provided by Amazon, these images are unregistered after 4 months, thereby breaking Terraform configs if we reference specific AMI. If on the other hand we would reference the latest image, that would cause the instances to be replaced.

Describe the solution you'd like.

I propose to add ami_replace_on_change property that would work analogous to user_data_replace_on_change. The default value would be true to be backwards compatible. This way we would be able to reference the latest image in our configs.

Describe alternatives you've considered.

Copying AMI, but it is not permitted.

Additional context

I can provide a PR if such a solution is accepted.

bryantbiggs commented 2 years ago

@IgorMilavec this has to be supported first by the AWS API and then by the AWS provider before we can support it here. Ref https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#user_data_replace_on_change

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.