Live data from Hacker News

Terraform Gotchas and How We Work Around Them

heap.engineering

1–10 of 82 posts

Re: Terraform Gotchas and How We Work Around Them

#4
post #2

Hey author here! Happy to answer any questions etc :-)

No questions, just a suggestion: implement the part where the terraform plan is added as a comment in the PR. We set this up at my current employer and it makes the review process much quicker (also, commenting on lines in the ~plan~ terraform code changes is the bee's knees).

Don't have the apply be automatic after a review is approved; terraform apply's occasionally go sideways and need human intervention (remember: rollbacks are not automatic). A human should always kick off the apply and monitor state change activity.

Re: Terraform Gotchas and How We Work Around Them

#5
post #2

Hey author here! Happy to answer any questions etc :-)

Great post! I too had the issue with AWS volume attachments and the need to separate them out. Luckily it happened early during some of my first provisioning and we realized it before standing up more databases. I now have a policy where each server has a separate EBS volume, using a volume attachment Terraform resource, for any data. Inline EBS volumes are just used for the OS.

I've run into another similar type issue now and I think that I'm going to have to do state surgery like you. I want to refactor some of my terraform resources into modules, but this changes the resource names. I can't see any way to do it without either standing up new infrastructure or modifying the state directly.

Re: Terraform Gotchas and How We Work Around Them

#8
post #2

Hey author here! Happy to answer any questions etc :-)

No questions, just a suggestion: implement the part where the terraform plan is added as a comment in the PR. We set this up at my current employer and it makes the review process much quicker (also, commenting on lines in the ~plan~ terraform code changes is the bee's knees). Don't have the apply be automatic after a review is approved; terraform apply's occasionally go sideways and need human intervention (remember…

I couldn't agree more with this, we do exactly the same and it works great for us. Plan on a comment and manual apply.

Re: Terraform Gotchas and How We Work Around Them

#9
post #2

Hey author here! Happy to answer any questions etc :-)

No questions, just a suggestion: implement the part where the terraform plan is added as a comment in the PR. We set this up at my current employer and it makes the review process much quicker (also, commenting on lines in the ~plan~ terraform code changes is the bee's knees). Don't have the apply be automatic after a review is approved; terraform apply's occasionally go sideways and need human intervention (remember…

Woah can you comment on lines in a comment? /me dashes to investigate github

And thanks for the suggestion. So far it's been on a someday maybe list, but if it really does help that much, maybe we'll bump it to someday maybe soon.

Re: Terraform Gotchas and How We Work Around Them

#10
post #5
post #2

Hey author here! Happy to answer any questions etc :-)

Great post! I too had the issue with AWS volume attachments and the need to separate them out. Luckily it happened early during some of my first provisioning and we realized it before standing up more databases. I now have a policy where each server has a separate EBS volume, using a volume attachment Terraform resource, for any data. Inline EBS volumes are just used for the OS. I've run into another similar type iss…

We ran into similar issues. From there I went one step further and wrote a tool to do the attachments for me (instead of using Terraform's aws_volume_attachment):

https://github.com/sevagh/goat

This way in Terraform I provision a group of volumes, a group of instances, and rely on `goat` to do the rest.

Post reply on HN