This code is just a representation on how you could apply rolling update to yours EC2 instances. Do not use it in production.
terraform --version
Terraform v0.13.1
packer --version
1.6.0
Instructions:
cd packer
packer build .
cd ..
terraform init
terraform apply
In another terminal:
while true; do
curl $(terraform output lb_dns)
sleep 1
done
cd packer
packer build -var 'color=blue' .
cd ..
terraform apply
terraform destroy
Deregister AMI from the console.