V
V
Vitaly Karasik2021-08-30 18:45:23
Amazon Web Services
Vitaly Karasik, 2021-08-30 18:45:23

Is Terraform suitable for updating an AMI image?

AWS has autoscaling groups / launch templates / target groups / ALBs.

From time to time, you need to update the AMIs used in launch templates - raise EC2 from the current AMI, run the script, create an updated AMI. Is Terraform suitable for this? I don't think so, but maybe I'm missing something?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim, 2021-08-30
@vitaly_il1

Kind, Terraform is not very good, it's like an end user. Use packer to upgrade - best inside CI/CD pipeline. After updating ami, update the launch template in terraform by simply pointing to the (new) version of ami for ec2 machines.
But... in terraform, you can specify user_data with a bash script to run during instance initiation
https://www.bogotobogo.com/DevOps/Terraform/Terraf...

S
Stanislav Bodrov, 2021-08-31
@jenki

From time to time you need to update AMIs used in launch templates
A clear hint at an immutable (immutable) infrastructure. Best practice suggests that a freshly baked image should be cleaned of unnecessary and everything necessary should be installed. Then everything is tested and verified.
Is Terraform suitable for this?
To deploy/upgrade with new AMI? Yes.
To create a new image with the required settings? In principle, you can wind up user data, but everything will not be the same style sooner. Ansible is more suitable for these purposes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question