cloudposse / terraform-aws-ec2-instance

Terraform module for provisioning a general purpose EC2 host
https://cloudposse.com/accelerate
Apache License 2.0
168 stars 221 forks source link

feat(aws_instance): add ignore_ami_changes option #209

Closed Lawstorant closed 1 month ago

Lawstorant commented 2 months ago

what

Allow ignoring AMI image ID changes. EC2 instance won't be recreated If the AMI image id is provided from a data source changes.

why

We use an aws_ami data Blocks that always provides the most recent version of selected image but that will cause the EC2 to recreate if the image is updated. We want to be able to upgrade only when we see fit.

nitrocode commented 2 months ago

Thanks for the pr @Lawstorant. Instead of updating the module, have you considered simply setting the ami input of the module? That should prevent your ec2 from getting recreated.

Also have you folks considered using an autoscaling group of 1 instance to have more control over the EC2s ? It might be better for your purposes.

Lawstorant commented 1 month ago

My problem is that I'm setting the ami input already, but the input data comes from a filter in a data source. Well, I'm going to filter it better and close this for now.