Upgrade to Pro — share decks privately, control downloads, hide ads and more …

plan & apply. rinse & repeat.

plan & apply. rinse & repeat.

Managing infrastructure and services using Terraform and Buildkite CI at Code Climate.

Code Climate addresses common challenges across engineering organizations with the adoption of tools and practices that bring automation and high visibility to changes in our infrastructure and services.

Avatar for Devon Blandin

Devon Blandin

July 10, 2018
Tweet

More Decks by Devon Blandin

Other Decks in Programming

Transcript

  1. plan & apply. rinse & repeat. Managing infrastructure and services

    using Terraform and Buildkite CI 1 Devon Blandin / Code Climate / USV DevOps Summit / July 10th, 2018
  2. desired state: what are our goals? 1. Easily propose, review,

    and apply changes to infrastructure 2. Allow for automated releases to production 3. Infrastructure and services should be easily placed into & out of maintenance mode 4. Operators should have timely, helpful notifications of deploy activity 5. Operators should have controls to roll back changes 2
  3. If you're using Terraform, every change you make is highly

    visible, remains in version control, and is discoverable within the git repository at any time. 7
  4. Allow for automated releases to production - We let CI

    deploy updates to services via terraform. - Operators execute any other changesets, also via terraform. 9
  5. Allow for automated releases to production 10 - Use remote

    state to store your configuration - Use remote state locking to prevent collisions
  6. Allow for automated releases to production build all the artifacts

    test the artifacts report test coverage + trigger next pipeline all branches 12
  7. Allow for automated releases to production /velocity_prod/app_image_ref /velocity_prod/consumer_image_ref /velocity_prod/agent_image_ref /velocity_prod/log_forwarder_s3_bucket

    /velocity_prod/log_forwarder_s3_bucket codeclimate/velocity-app:b100 codeclimate/velocity-consumer:b100 codeclimate/velocity-agent:b100 com.codeclimate.velocity.assets log_forwarder/package_b100.zip master 14
  8. Allow for automated releases to production AccessDeniedException: User: arn:aws:sts::208491357083:assumed-role/velocity-prod-terraform-ci/1529374107443555604 is

    not authorized to perform: kinesis:UpdateShardCount on resource: arn:aws:kinesis:us-east-1:208491357083:stream/velocity-prod-agent-high 21
  9. The failing build encourages an operator to take control and

    run `terraform apply` locally if it’s a change they expect. 22
  10. Our infrastructure and services should be easy to put into

    maintenance mode /velocity_prod/maintenance true apply enable maintenance mode apply the change 24
  11. Easily propose, review, and apply changes to infrastructure - PRs

    for Terraform config changes - CI and local terraform invocations - Remote state and state locking - Parameter Store for config values 40
  12. Allow for automated releases to production - One pipeline for

    artifact build & test - Separate pipeline for terraform ops - Limited IAM policy for CI - Allow CI to update existing services - Build error trigger to run locally 41
  13. Infrastructure and services should be easily placed into & out

    of maintenance mode - Parameter Store param: true/false - Trickles down through TF config - Swaps image for web services - Scales down non-web services - Continue to merge if you want 42
  14. Operators should have controls to roll back changes - Rollback

    instructions - Parameter Store artifact references - Trigger new “ops” build 44
  15. Devon Blandin / Code Climate / USV DevOps Summit /

    July 10th, 2018 Fin. Thanks! Some additional resources: https://segment.com/blog/rebuilding-our-infrastructure/ https://zwischenzugs.com/2017/02/21/terraform-and-dynamic-environments/ https://charity.wtf/tag/terraform/ https://blog.gruntwork.io/how-to-create-reusable-infrastructure-with-terraform-modules-25526d65f73d https://medium.com/@petey5000/petes-terraform-tips-694a3c4c5169 45