cloudposse / terraform-aws-ec2-instance

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

feat(aws_instance): add ignore_ami_changes option #209

Closed Lawstorant closed 4 days ago

Lawstorant commented 4 weeks 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 4 weeks 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 4 days 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.