Blue Green Deployments with Terraform

1,761 views
Skip to first unread message

Glenn Poston

unread,
Apr 7, 2015, 9:11:46 PM4/7/15
to terrafo...@googlegroups.com
I'm trying to use terraform to do part of our blue/green deployments.

What I'd like to do is similar to the 'create_before_destroy' lifecycle event, but what I really want is 'create_dont_destroy'.

We have a template to create an elb, launch config, and associated ASG.  We pass the AMI for the launch config into the template as a variable.

What I'd like to happen when I run terraform (and pass in an AMI different than the one that's currently associated w/ the launch config/ASG) is for terraform to create a new launch config and ASG, but not touch/delete/modify the old one.

Then I can (via some other means i.e. Amazon API) stop traffic to the original ASG and eventually terminate it after validating the deploy is 'good'.

Obviously there's no 'create _dont_destroy' option right now, but I was wondering if there might be some other terraform trick that I'm not aware of.

Mitchell Hashimoto

unread,
Apr 20, 2015, 12:45:23 PM4/20/15
to Glenn Poston, <terraform-tool@googlegroups.com>
Glenn,


@phinze is a core comitter on Terraform, as well.

Best,
Mitchell

--
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To post to this group, send email to terrafo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/2983d3c2-3acf-4f63-9a73-b5ec3fe2205c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

José Coelho

unread,
Apr 22, 2015, 11:33:55 AM4/22/15
to terrafo...@googlegroups.com, gpo...@clearcareonline.com
Hi,

This example is interesting, however:

- For every single deploy I will have to edit the instance numbers?
- Terraform will wait for the connection draining?

This approach don't seem to scale out if I have 30 different services.

Thank you,
José Coelho

Glenn Poston

unread,
Apr 27, 2015, 12:32:02 PM4/27/15
to terrafo...@googlegroups.com, gpo...@clearcareonline.com
I just open sourced a project that takes a slightly different approach to blue/green deployments.  It has the added benefit of supporting multiple 'blue state' ASG's so that an instant rollback can be made to several versions/AMIs back.


Do you think that this approach (which requires manual modification of the tfstate file) will work long term, given terraform's roadmap?

Also, I think that this approach will work w/ ATLAS as long as you do a 'terraform remote pull', before modifying the state file... and then 'terraform remote push' afterwards, but I can't test this until I can change variables before during a terraform apply (to change the AMI).

Thoughts?
Reply all
Reply to author
Forward
0 new messages