Hello, Terraform 👋
Building up to a real-world use case
Matt Christie – Data Engineer II: Technical Lead
Gibbs Land Use and Environment Lab (GLUE)
Background
Our use case
Background
Hello, Terraform
Background
Hello, Terraform
*We call these instances "build servers"
Background
Hello, Terraform
Background
Hello, Terraform
(i.e. build servers don't need to be up indefinitely)
Background
Hello, Terraform
Background
Hello, Terraform
This is because server setup is a tedious manual process; developers try to batch multiple pipeline runs to avoid setup overhead
Background
Hello, Terraform
Solution: Terraform
Automate build server setup + teardown
Bill of Materials
Hello, Terraform
git push
SSH
EC2
DB
Runner
submit job
remote files
Bill of Materials
Hello, Terraform
git push
SSH
EC2
DB
Runner
submit job
remote files
Itemize these and develop Terraform configuration incrementally
1
2
4
3
5
Sidebar: Development Philosophy
Hello, Terraform
Sidebar: Development Philosophy
Hello, Terraform
Do we want Terraform or not?? There's always future work 😀
Implementation: A step-by-step process
Hello, Terraform
This part will be mostly interactive, but see notes below for a summary
Step 1: EC2 instance
Hello, Terraform
Separation of concerns: Demonstrate that Terraform can bring resources up and down without troubleshooting complex configuration
Step 2: SSH
Hello, Terraform
Managing security groups with Terraform enables tighter access controls
Step 3: Data volume
Hello, Terraform
EBS volumes can be mounted by AWS volume ID to avoid device name mapping issues
Step 4: Remote files
Hello, Terraform
I decided to keep the existing stateful solution for now, though its corresponding security group rule is being managed with Terraform
Step 5: GitLab Runner
Hello, Terraform
This and other processes can be initialized in user_data
Retrospective
Lessons and future work
Value Added
Hello, Terraform
Value Added
Hello, Terraform
Setup:
Teardown:
Takeaways
Hello, Terraform
Takeaways
Hello, Terraform
Ex. How stateful do we want our AMI to be?
Takeaways
Hello, Terraform
Takeaways
Hello, Terraform
Ex. Managing a security group scoped exclusively to a short-lived EC2 instance. Shout-out to cloud office hours for suggesting this!
Takeaways
Hello, Terraform
Takeaways
Hello, Terraform
This feels counter to Terraform's design philosophy in that it kicks the resource management can down the road. Any providers that explicitly model system resources? (ex. mounts, processes, etc.)
Takeaways
Hello, Terraform
Takeaways
Hello, Terraform
I spent a half-day unsuccessfully troubleshooting minor improvements to the remote file mount, but the more conservative solution was much simpler and made a complete project possible
Learning 📈
Hello, Terraform
Learning 📈
Hello, Terraform
Something to think about: Providers are very powerful. This project used the AWS provider almost exclusively, but Terraform isn't restricted to managing cloud infrastructure. What other problem spaces could benefit from managing declared state?
Roadmap (potential work items)
Hello, Terraform
Thank you!