SlideShare a Scribd company logo
Terraform GitOps
How to do Operations by Pull Request
<hello@cloudposse.com>
https://cloudposse.com/
@cloudposse
+
What to Expect
Feelings of OMG
Aha! Moments...
Totally Sweet Ops
What is GitOps? (not rocket science)
Why it’s awesome (and you’ll agree)
How to get started… (our way)
And...
Live demo. . ..
Q&A . ...
Who is this dude?
Founder of a DevOps Professional Services Company
We’ve pioneered
Collaborative DevOps for Companies
(cloudposse.com)
SweetOps M
e
(Erik
Osterman)
( 100% Open Source )
Infrastructure as a Service
Everything as Code, SDNs
Serverless & Lambdas
Mesh Networking, Operators
Container Management Platforms
CI/CD Everywhere, ChatOps, GitOps
DevOps Renaissance
(kubernetes, ecs, mesos, swarm)
DevOps
Complicated Manual Rollouts via the terminal
Poor Audit Trails (huge risk)
Not clear what’s been deployed
Out of date documentation
No one knows how to make changes
The
“Industry”
(configuration drift)
Terraform more problems
Deploying infrastructure is not like deploying a web app
(no easy rollbacks)
Terraform is more like a database migration tool
Terraform does not automatically rollback on errors
Terraform plans are a best guess of what’s to happen
Terraform apply will regularly fail
Terraform apply on merge risks destabilizing master
I test some changes at home...
For Example….
“I ^ it worked...
on my machine.”
SWEAR .
Then comes… Launch Day
Production
The Math is Simple
A*B*C*D*E*F = impossible to manage
A = # of tools pinned to versions
B = # of dependencies pinned to versions
C = # of AWS accounts
D = # of project environments (per acct)
E = # of number of developers
F = # of customers (our case)
Too many
permutations to
keep straight
This is why we don’t run things “natively”
Terraform GitOps on Codefresh
So….
Let’s fix
this.
Goal:
Make it Easy to Terraform Stuff.
(e.g. enable anyone on team to easily spin up RDS Database with Terraform)
Let’s Practice GitOps.
Use Git as a System of Record for the desired state of configuration
Do Operations by Pull Request for Infrastructure as Code
Then use Continuous Delivery to apply changes to infrastructure
(basically it’s a CI/CD for DevOps)
See output from terraform in GitHub comments
(E.g. “Plan: 23 to add, 2 to change, 15 to destroy.”)
GitOps Objectives
Repeatable - Apply changes the same way every time
(even your entire stack all at once!)
Predictable - Know what’s going to happen
(e.g. before you merge)
Auditable - See what was done
(e.g. when things were applied. see if there were errors)
Accessible - Anyone who can open a PR can contribute
The Solution
https://codefresh.io
Automate Anything
(if it runs in a container)
How We Use Codefresh
Terraform
Cloud Formation
Helm → K8S
Helmfile
Because we can
run any command
But will it work with...
Terragrunt? YES
GITLAB? YES
BITBUCKET? YES
ANSIBLE? YES
About Codefresh
Yet another CI/CD solution, only better.
1. Stick everything you want to automate into containers
2. String containers together in a pipeline, run them in parallel
3. Trigger pipelines on webhooks, comments, releases, etc.
Slack Notifications Approval Steps GitHub Comments
Basic Flow Diagram
“Interactive”
Pull Requests
The “Git Workflow”
Step One: Open Pull Request
Step Two: Review “Auto Plan”
Step Three: Seek Approval
Code Review
Step Four: Deploy Changes
Step Five: Merge Pull Request
Sneak Peak
That was
easy.
How to get started
1. Signup for Codefresh
2. Add codefresh.yaml to each terraform repo
3. Get back to work (sorry it’s that easy).
Or ask us for help =)
Example /codefresh.yaml.
init:
title: Run `terraform init`
stage: Init
fail_fast: true
image: ${{build_image}}
working_directory: *cwd
environment:
- TF_COMMAND=init
commands:
- eval "$(chamber exec atlantis -- sh -c "export -p")"
- eval "$(ssh-agent)"
- echo "${ATLANTIS_SSH_PRIVATE_KEY}" | ssh-add -
- terraform init
# define step called “init”
# give it a title
# associate it with a stage of the pipeline
# exit on errors
# docker image to use
# working directory (e.g. terraform code)
# environment variables
# (used for our github comment template)
# commands we should run in this step
# export environment from chamber to shell
# start an SSH agent
# load SSH key so we can pull private repos
# run terraform init with s3 backend
Steps can be Entirely Customized.
Init Step
Example codefresh.yaml. (Continued)
plan:
title: Run `terraform plan`
stage: Plan
fail_fast: true
image: ${{build_image}}
working_directory: *cwd
environment:
- TF_COMMAND=plan
commands:
- set +e -xo pipefail
- terraform plan | tfmask | scenery | tee plan.txt
- export TF_EXIT_CODE=$?
- github-commenter < plan.txt
- '[ $TF_EXIT_CODE -ne 1 ]'
# define step called “init”
# give it a title
# associate it with a stage of the pipeline
# exit on errors
# docker image to use
# working directory (e.g. terraform code)
# environment variables
# (used for our github comment template)
# commands we should run in this step
# shell flags
# terraform plan, mask secrets, format it
# record exit code of terraform plan
# comment back to PR with plan output
# exit code of 0 or 2 is success; 1 is error
Steps can be Entirely Customized.
PLan Step
Example codefresh.yaml. (Continued)
apply:
title: Run `terraform apply`
stage: Apply
fail_fast: true
image: ${{build_image}}
working_directory: *cwd
environment:
- TF_COMMAND=apply
commands:
- set +e -xo pipefail
- terraform apply | tfmask | tee apply.txt
- export TF_EXIT_CODE=$?
- github-commenter < apply.txt
- '[ $TF_EXIT_CODE -eq 0 ]'
# define step called “apply”
# give it a title
# associate it with a stage of the pipeline
# exit on errors
# docker image to use
# working directory (e.g. terraform code)
# environment variables
# (used for our github comment template)
# commands we should run in this step
# shell flags
# apply the terraform plan and mask output
# (run apply using previous plan)
# $PLANFILE ensures WYSIWYG
# Comment back on github with outcome
# Expect an exit code of zero
Apply Step
Live Demo
1. Add User
2. Open PR
3. Run Plan
4. Seek Approval (or not)
5. Apply
6. Merge
Demo Time!
Our Best Practices
Use Geodesic as our cloud automation shell
Use IAM STS for short lived AWS credentials (not hardcoded credentials)
Use GitHub CODEOWNERS
Use .tfvars for non-secrets
Use SSM Parameter Store + KMS for Secrets
Use scenery for clean output; tfmask to sanitize output
Atlantis
“Best Practices”
Why do you care?
Teamwork.
GitOps
Stop living dangerously.
Start using GitOps.
https://github.com/runatlantis/atlantis
● Practice total transparency in operations
● Enable team collaboration
● Reduce access to environments → increase security
● Increase Productivity, Simplify Maintenance, Ensure Repeatability
Where can I ask questions?
slack.sweetops.com
Join our community!
Links
Example Pipeline on GitHub
cpco.io/codefresh-gitops
github.com/cloudposse/tfmask
github.com/cloudposse/geodesic
github.com/cloudposse/github-commenter
Office Hours with Cloud Posse
● Expert Advice — Prescriptive solutions to your questions
● Reduced Time to Market — know your options & eliminate analysis paralysis
● Trusted Partner — who learns your stack and understands your problems
● Recorded Strategy Sessions — Weekly or Biweekly Cadence (30m-1hr)
● Easy Scheduling — via Calendly or recurring events
● Shared Slack Channel — for private communications (~12 hour SLA)
What you get...
Why you want it...
 $500/mo - 2 hours 
Hire us. =)
A Totally Sweet DevOps Professional Services Company
100+ Free Terraform Modules github.com/cloudposse
Active Community sweetops.com/slack
Awesome Documentation docs.cloudposse.com
415
5
3
5
86
15
hello@
cloudposse.com
(free consultation)

More Related Content

What's hot (20)

PDF
Getting Started with Kubernetes
VMware Tanzu
 
PDF
Introduction to GitHub Actions
Bo-Yi Wu
 
PDF
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Edureka!
 
PDF
Introduction to CICD
Knoldus Inc.
 
PPTX
Monitoring, Logging and Tracing on Kubernetes
Martin Etmajer
 
PPTX
Introduction to Helm
Harshal Shah
 
PDF
Github - Git Training Slides: Foundations
Lee Hanxue
 
PDF
Introduction to GitHub Actions
Knoldus Inc.
 
PDF
Introduction to Github Actions
Knoldus Inc.
 
PPTX
Introduction to helm
Jeeva Chelladhurai
 
PPTX
Using Azure DevOps to continuously build, test, and deploy containerized appl...
Adrian Todorov
 
PPTX
BitBucket presentation
Jonathan Lawerh
 
PPTX
Transforming Organizations with CI/CD
Cprime
 
PPTX
Kubernetes Introduction
Martin Danielsson
 
PDF
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
Edureka!
 
PPTX
Meetup 23 - 03 - Application Delivery on K8S with GitOps
Vietnam Open Infrastructure User Group
 
PDF
Gitlab, GitOps & ArgoCD
Haggai Philip Zagury
 
PPTX
GitOps - Modern best practices for high velocity app dev using cloud native t...
Weaveworks
 
PPTX
An introduction to DevOps
Alexander Meijers
 
PDF
ArgoCD Meetup PPT final.pdf
amanmakwana3
 
Getting Started with Kubernetes
VMware Tanzu
 
Introduction to GitHub Actions
Bo-Yi Wu
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Edureka!
 
Introduction to CICD
Knoldus Inc.
 
Monitoring, Logging and Tracing on Kubernetes
Martin Etmajer
 
Introduction to Helm
Harshal Shah
 
Github - Git Training Slides: Foundations
Lee Hanxue
 
Introduction to GitHub Actions
Knoldus Inc.
 
Introduction to Github Actions
Knoldus Inc.
 
Introduction to helm
Jeeva Chelladhurai
 
Using Azure DevOps to continuously build, test, and deploy containerized appl...
Adrian Todorov
 
BitBucket presentation
Jonathan Lawerh
 
Transforming Organizations with CI/CD
Cprime
 
Kubernetes Introduction
Martin Danielsson
 
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
Edureka!
 
Meetup 23 - 03 - Application Delivery on K8S with GitOps
Vietnam Open Infrastructure User Group
 
Gitlab, GitOps & ArgoCD
Haggai Philip Zagury
 
GitOps - Modern best practices for high velocity app dev using cloud native t...
Weaveworks
 
An introduction to DevOps
Alexander Meijers
 
ArgoCD Meetup PPT final.pdf
amanmakwana3
 

Similar to Terraform GitOps on Codefresh (20)

PDF
Git ops & Continuous Infrastructure with terra*
Haggai Philip Zagury
 
PDF
Terraforming your Infrastructure on GCP
Samuel Chow
 
PPTX
Hashiconf Israel 2022 - Terraform Pull Request Automation.pptx
Tal Hibner
 
PPTX
"Continuously delivering infrastructure using Terraform and Packer" training ...
Anton Babenko
 
PDF
Managing GCP Projects with Terraform (devfest Pisa 2018)
Giovanni Toraldo
 
PPTX
RIMA-Infrastructure as a code with Terraform.pptx
MrJustbis
 
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
ssuser705051
 
PDF
Terraform-2.pdf
rutiksankapal21
 
PDF
Getting Started with DevOps on AWS [Mar 2020]
Dhaval Nagar
 
PPTX
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
Adin Ermie
 
PPTX
Automatic Terraform Execution powerpoint
ssuserda3c5d1
 
PDF
Successful DevOps implementation for small teams a true story
Jakub Paweł Głazik
 
PDF
Self-service PR-based Terraform
Andrew Kirkpatrick
 
PDF
Gotchas using Terraform in a secure delivery pipeline
Anton Babenko
 
PDF
Terraform introduction
Jason Vance
 
PDF
The hitchhiker's guide to terraform your infrastructure
Fernanda Martins
 
PPTX
An intro to Docker, Terraform, and Amazon ECS
Yevgeniy Brikman
 
PPTX
Terraform in production - experiences, best practices and deep dive- Piotr Ki...
PROIDEA
 
PPTX
Infrastructure as code with terraform and packer
Alex Landa
 
PDF
Best Practices of Infrastructure as Code with Terraform
DevOps.com
 
Git ops & Continuous Infrastructure with terra*
Haggai Philip Zagury
 
Terraforming your Infrastructure on GCP
Samuel Chow
 
Hashiconf Israel 2022 - Terraform Pull Request Automation.pptx
Tal Hibner
 
"Continuously delivering infrastructure using Terraform and Packer" training ...
Anton Babenko
 
Managing GCP Projects with Terraform (devfest Pisa 2018)
Giovanni Toraldo
 
RIMA-Infrastructure as a code with Terraform.pptx
MrJustbis
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
ssuser705051
 
Terraform-2.pdf
rutiksankapal21
 
Getting Started with DevOps on AWS [Mar 2020]
Dhaval Nagar
 
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
Adin Ermie
 
Automatic Terraform Execution powerpoint
ssuserda3c5d1
 
Successful DevOps implementation for small teams a true story
Jakub Paweł Głazik
 
Self-service PR-based Terraform
Andrew Kirkpatrick
 
Gotchas using Terraform in a secure delivery pipeline
Anton Babenko
 
Terraform introduction
Jason Vance
 
The hitchhiker's guide to terraform your infrastructure
Fernanda Martins
 
An intro to Docker, Terraform, and Amazon ECS
Yevgeniy Brikman
 
Terraform in production - experiences, best practices and deep dive- Piotr Ki...
PROIDEA
 
Infrastructure as code with terraform and packer
Alex Landa
 
Best Practices of Infrastructure as Code with Terraform
DevOps.com
 
Ad

More from Codefresh (20)

PDF
Detect, debug, deploy with Codefresh and Lightstep
Codefresh
 
PDF
CICD Pipelines for Microservices: Lessons from the Trenches
Codefresh
 
PDF
Simplify Your Code with Helmfile
Codefresh
 
PDF
Making the Most of Helm 3 with Codefresh
Codefresh
 
PDF
5 Simple Tips for Troubleshooting Your Kubernetes Pods
Codefresh
 
PDF
Best Practices for Microservice CI/CD: Lessons from Expedia and Codefresh
Codefresh
 
PDF
Hybrid CI/CD with Kubernetes & Codefresh
Codefresh
 
PDF
VM vs Docker-Based Pipelines
Codefresh
 
PDF
Why You Should be Using Multi-stage Docker Builds in 2019
Codefresh
 
PPTX
Deploy Secure Cloud-Native Apps Fast
Codefresh
 
PDF
CICD Pipelines for Microservices Best Practices
Codefresh
 
PDF
Codefresh CICD New Features Launch! May 2019
Codefresh
 
PDF
Adding Container Image Scanning to Your Codefresh Pipelines with Anchore
Codefresh
 
PDF
Image scanning using Clair
Codefresh
 
PDF
Updating Kubernetes With Helm Charts: Build, Test, Deploy with Codefresh and...
Codefresh
 
PDF
Docker based-Pipelines with Codefresh
Codefresh
 
PDF
Automated Serverless Pipelines with #GitOps on Codefresh
Codefresh
 
PDF
Discovering and Fixing Dependency Vulnerabilities for Kubernetes apps with Sn...
Codefresh
 
PDF
Net Pipeline on Windows Kubernetes
Codefresh
 
PPTX
Multi-cloud CI/CD with failover powered by K8s, Istio, Helm, and Codefresh
Codefresh
 
Detect, debug, deploy with Codefresh and Lightstep
Codefresh
 
CICD Pipelines for Microservices: Lessons from the Trenches
Codefresh
 
Simplify Your Code with Helmfile
Codefresh
 
Making the Most of Helm 3 with Codefresh
Codefresh
 
5 Simple Tips for Troubleshooting Your Kubernetes Pods
Codefresh
 
Best Practices for Microservice CI/CD: Lessons from Expedia and Codefresh
Codefresh
 
Hybrid CI/CD with Kubernetes & Codefresh
Codefresh
 
VM vs Docker-Based Pipelines
Codefresh
 
Why You Should be Using Multi-stage Docker Builds in 2019
Codefresh
 
Deploy Secure Cloud-Native Apps Fast
Codefresh
 
CICD Pipelines for Microservices Best Practices
Codefresh
 
Codefresh CICD New Features Launch! May 2019
Codefresh
 
Adding Container Image Scanning to Your Codefresh Pipelines with Anchore
Codefresh
 
Image scanning using Clair
Codefresh
 
Updating Kubernetes With Helm Charts: Build, Test, Deploy with Codefresh and...
Codefresh
 
Docker based-Pipelines with Codefresh
Codefresh
 
Automated Serverless Pipelines with #GitOps on Codefresh
Codefresh
 
Discovering and Fixing Dependency Vulnerabilities for Kubernetes apps with Sn...
Codefresh
 
Net Pipeline on Windows Kubernetes
Codefresh
 
Multi-cloud CI/CD with failover powered by K8s, Istio, Helm, and Codefresh
Codefresh
 
Ad

Recently uploaded (20)

PDF
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
Edge AI and Vision Alliance
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Priyanka Aash
 
PDF
Open Source Milvus Vector Database v 2.6
Zilliz
 
PPTX
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
Edge AI and Vision Alliance
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Priyanka Aash
 
Open Source Milvus Vector Database v 2.6
Zilliz
 
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 

Terraform GitOps on Codefresh

  • 1. Terraform GitOps How to do Operations by Pull Request <[email protected]> https://cloudposse.com/ @cloudposse +
  • 2. What to Expect Feelings of OMG Aha! Moments... Totally Sweet Ops What is GitOps? (not rocket science) Why it’s awesome (and you’ll agree) How to get started… (our way) And... Live demo. . .. Q&A . ...
  • 3. Who is this dude? Founder of a DevOps Professional Services Company We’ve pioneered Collaborative DevOps for Companies (cloudposse.com) SweetOps M e (Erik Osterman) ( 100% Open Source )
  • 4. Infrastructure as a Service Everything as Code, SDNs Serverless & Lambdas Mesh Networking, Operators Container Management Platforms CI/CD Everywhere, ChatOps, GitOps DevOps Renaissance (kubernetes, ecs, mesos, swarm)
  • 5. DevOps Complicated Manual Rollouts via the terminal Poor Audit Trails (huge risk) Not clear what’s been deployed Out of date documentation No one knows how to make changes The “Industry” (configuration drift)
  • 6. Terraform more problems Deploying infrastructure is not like deploying a web app (no easy rollbacks) Terraform is more like a database migration tool Terraform does not automatically rollback on errors Terraform plans are a best guess of what’s to happen Terraform apply will regularly fail Terraform apply on merge risks destabilizing master
  • 7. I test some changes at home... For Example….
  • 8. “I ^ it worked... on my machine.” SWEAR .
  • 9. Then comes… Launch Day Production
  • 10. The Math is Simple A*B*C*D*E*F = impossible to manage A = # of tools pinned to versions B = # of dependencies pinned to versions C = # of AWS accounts D = # of project environments (per acct) E = # of number of developers F = # of customers (our case) Too many permutations to keep straight This is why we don’t run things “natively”
  • 13. Goal: Make it Easy to Terraform Stuff. (e.g. enable anyone on team to easily spin up RDS Database with Terraform)
  • 14. Let’s Practice GitOps. Use Git as a System of Record for the desired state of configuration Do Operations by Pull Request for Infrastructure as Code Then use Continuous Delivery to apply changes to infrastructure (basically it’s a CI/CD for DevOps) See output from terraform in GitHub comments (E.g. “Plan: 23 to add, 2 to change, 15 to destroy.”)
  • 15. GitOps Objectives Repeatable - Apply changes the same way every time (even your entire stack all at once!) Predictable - Know what’s going to happen (e.g. before you merge) Auditable - See what was done (e.g. when things were applied. see if there were errors) Accessible - Anyone who can open a PR can contribute
  • 17. Automate Anything (if it runs in a container)
  • 18. How We Use Codefresh Terraform Cloud Formation Helm → K8S Helmfile Because we can run any command
  • 19. But will it work with... Terragrunt? YES GITLAB? YES BITBUCKET? YES ANSIBLE? YES
  • 20. About Codefresh Yet another CI/CD solution, only better. 1. Stick everything you want to automate into containers 2. String containers together in a pipeline, run them in parallel 3. Trigger pipelines on webhooks, comments, releases, etc. Slack Notifications Approval Steps GitHub Comments
  • 24. Step One: Open Pull Request
  • 25. Step Two: Review “Auto Plan”
  • 26. Step Three: Seek Approval Code Review
  • 27. Step Four: Deploy Changes
  • 28. Step Five: Merge Pull Request
  • 31. How to get started 1. Signup for Codefresh 2. Add codefresh.yaml to each terraform repo 3. Get back to work (sorry it’s that easy). Or ask us for help =)
  • 32. Example /codefresh.yaml. init: title: Run `terraform init` stage: Init fail_fast: true image: ${{build_image}} working_directory: *cwd environment: - TF_COMMAND=init commands: - eval "$(chamber exec atlantis -- sh -c "export -p")" - eval "$(ssh-agent)" - echo "${ATLANTIS_SSH_PRIVATE_KEY}" | ssh-add - - terraform init # define step called “init” # give it a title # associate it with a stage of the pipeline # exit on errors # docker image to use # working directory (e.g. terraform code) # environment variables # (used for our github comment template) # commands we should run in this step # export environment from chamber to shell # start an SSH agent # load SSH key so we can pull private repos # run terraform init with s3 backend Steps can be Entirely Customized. Init Step
  • 33. Example codefresh.yaml. (Continued) plan: title: Run `terraform plan` stage: Plan fail_fast: true image: ${{build_image}} working_directory: *cwd environment: - TF_COMMAND=plan commands: - set +e -xo pipefail - terraform plan | tfmask | scenery | tee plan.txt - export TF_EXIT_CODE=$? - github-commenter < plan.txt - '[ $TF_EXIT_CODE -ne 1 ]' # define step called “init” # give it a title # associate it with a stage of the pipeline # exit on errors # docker image to use # working directory (e.g. terraform code) # environment variables # (used for our github comment template) # commands we should run in this step # shell flags # terraform plan, mask secrets, format it # record exit code of terraform plan # comment back to PR with plan output # exit code of 0 or 2 is success; 1 is error Steps can be Entirely Customized. PLan Step
  • 34. Example codefresh.yaml. (Continued) apply: title: Run `terraform apply` stage: Apply fail_fast: true image: ${{build_image}} working_directory: *cwd environment: - TF_COMMAND=apply commands: - set +e -xo pipefail - terraform apply | tfmask | tee apply.txt - export TF_EXIT_CODE=$? - github-commenter < apply.txt - '[ $TF_EXIT_CODE -eq 0 ]' # define step called “apply” # give it a title # associate it with a stage of the pipeline # exit on errors # docker image to use # working directory (e.g. terraform code) # environment variables # (used for our github comment template) # commands we should run in this step # shell flags # apply the terraform plan and mask output # (run apply using previous plan) # $PLANFILE ensures WYSIWYG # Comment back on github with outcome # Expect an exit code of zero Apply Step
  • 35. Live Demo 1. Add User 2. Open PR 3. Run Plan 4. Seek Approval (or not) 5. Apply 6. Merge
  • 37. Our Best Practices Use Geodesic as our cloud automation shell Use IAM STS for short lived AWS credentials (not hardcoded credentials) Use GitHub CODEOWNERS Use .tfvars for non-secrets Use SSM Parameter Store + KMS for Secrets Use scenery for clean output; tfmask to sanitize output Atlantis “Best Practices”
  • 38. Why do you care? Teamwork.
  • 39. GitOps Stop living dangerously. Start using GitOps. https://github.com/runatlantis/atlantis ● Practice total transparency in operations ● Enable team collaboration ● Reduce access to environments → increase security ● Increase Productivity, Simplify Maintenance, Ensure Repeatability
  • 40. Where can I ask questions? slack.sweetops.com Join our community!
  • 41. Links Example Pipeline on GitHub cpco.io/codefresh-gitops github.com/cloudposse/tfmask github.com/cloudposse/geodesic github.com/cloudposse/github-commenter
  • 42. Office Hours with Cloud Posse ● Expert Advice — Prescriptive solutions to your questions ● Reduced Time to Market — know your options & eliminate analysis paralysis ● Trusted Partner — who learns your stack and understands your problems ● Recorded Strategy Sessions — Weekly or Biweekly Cadence (30m-1hr) ● Easy Scheduling — via Calendly or recurring events ● Shared Slack Channel — for private communications (~12 hour SLA) What you get... Why you want it...  $500/mo - 2 hours 
  • 43. Hire us. =) A Totally Sweet DevOps Professional Services Company 100+ Free Terraform Modules github.com/cloudposse Active Community sweetops.com/slack Awesome Documentation docs.cloudposse.com 415 5 3 5 86 15 hello@ cloudposse.com (free consultation)