Slide 1

Slide 1 text

Patterns In Infrastructure as Code Takeshi Kondo / @chaspy Infra Study Meetup #1

Slide 2

Slide 2 text

Passed

Slide 3

Slide 3 text

Agenda • Infrastructure as Code in Quipper • Patterns in Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern

Slide 4

Slide 4 text

Agenda • Infrastructure as Code in Quipper • Patterns in Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern • What • Why • Point • Example

Slide 5

Slide 5 text

Agenda • Infrastructure as Code in Quipper • Patterns in Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern

Slide 6

Slide 6 text

Infrastructure as Code in Quipper (1) • Infrastructure / Cloud (AWS) • Terraform • Codenize.tools (Miam, Roadworker) • Application Platform (Kubernetes) • Kube-aws • Server Provisioning • Ansible

Slide 7

Slide 7 text

Infrastructure as Code in Quipper (2) • SaaS Configuration • Datadog • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables

Slide 8

Slide 8 text

Infrastructure as Code in Quipper(2) • SaaS Configuration • Datadog • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables Terraform Codenize.tools (Barkdog) circleci-env (Internal tool)

Slide 9

Slide 9 text

Infrastructure as Code in Quipper(2) • SaaS Configuration • Datadog • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables Terraform Codenize.tools (Barkdog) circleci-env (Internal tool)

Slide 10

Slide 10 text

Infrastructure as Code in Quipper(2) • SaaS Configuration • Datadog • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables Terraform Codenize.tools (Barkdog) circleci-env (Internal tool)

Slide 11

Slide 11 text

Agenda • Infrastructure as Code in Quipper • Patterns in Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern • What • Why • Point • Example

Slide 12

Slide 12 text

Environment Pattern

Slide 13

Slide 13 text

Environment Pattern Production Resource Staging Resource Staging Code Production Code Infrastructure as Code - Chapter 9. Patterns for Defining Infrastructure Apply Apply Change Change

Slide 14

Slide 14 text

Environment Pattern: Why • To minimize blast radius • To test before releasing to production

Slide 15

Slide 15 text

Environment Pattern: Point • Don’t Repeat Yourself • Minimize commonality • Keep it simple stupid • Enforcing, not communize Infrastructure as Code - 9.2.7 Approaches to Sharing Definitions

Slide 16

Slide 16 text

Environment Pattern: Example services ᵓᴷᴷ hoge-service ᴹ ᵓᴷᴷ production ᴹ ᴹ ᵓᴷᴷ aurora.tf ᴹ ᴹ ᵓᴷᴷ main.tf ᴹ ᴹ ᵓᴷᴷ provider.tf ᴹ ᴹ ᵓᴷᴷ terraform.tf ᴹ ᴹ ᵓᴷᴷ terraform.tfvars ᴹ ᴹ ᵓᴷᴷ variables.tf ᴹ ᴹ ᵋᴷᴷ versions.tf ᴹ ᵋᴷᴷ staging ᴹ ᵓᴷᴷ aurora.tf ᴹ ᵓᴷᴷ main.tf ᴹ ᵓᴷᴷ provider.tf ᴹ ᵓᴷᴷ terraform.tf ᴹ ᵓᴷᴷ terraform.tfvars ᴹ ᵓᴷᴷ variables.tf ᴹ ᵋᴷᴷ versions.tf ᵋᴷᴷ modules Terraform ansible ᵋᴷᴷ ubuntu1804 ᵓᴷᴷ reverse-proxy-production ᴹ ᵓᴷᴷ goss ᴹ ᵓᴷᴷ group_vars ᴹ ᴹ ᵓᴷᴷ all.yml ᴹ ᴹ ᵓᴷᴷ development.yml ᴹ ᴹ ᵋᴷᴷ staging.yml ᴹ ᵓᴷᴷ hosts-development ᴹ ᵓᴷᴷ hosts-test ᴹ ᵓᴷᴷ roles ᴹ ᴹ ᵋᴷᴷ nginx ᴹ ᴹ ᵓᴷᴷ files ᴹ ᴹ ᵓᴷᴷ tasks ᴹ ᴹ ᵋᴷᴷ templates ᴹ ᵋᴷᴷ site.yml ᵓᴷᴷ reverse-proxy-staging ᵓᴷᴷ common-roles ᵓᴷᴷ datadog ᵓᴷᴷ td-agent Ansible

Slide 17

Slide 17 text

Scaffold Pattern

Slide 18

Slide 18 text

Scaffold Pattern Template Input variable Code Generate

Slide 19

Slide 19 text

Scaffold Pattern: Why • To make self-service easier • Reduce cognitive load Infrastructure as Code - 9.1.6 Self-Service Environments

Slide 20

Slide 20 text

Scaffold Pattern: Point • Write a document • Make each program do one thing well https://en.wikipedia.org/wiki/Unix_philosophy

Slide 21

Slide 21 text

Scaffold Pattern: Example • Create new application with Kubernetes manifest • Create new resource with Terraform HCL • Create AWS Aurora resource definition • Create Datadog SLO Definition

Slide 22

Slide 22 text

Create AWS Aurora resource definition

Slide 23

Slide 23 text

Backup Pattern

Slide 24

Slide 24 text

Backup Pattern Code Resource Import Change manually

Slide 25

Slide 25 text

Backup Pattern Code Resource Import Change manually Apply

Slide 26

Slide 26 text

Backup Pattern: Why • Easy to change from GUI (especially SaaS Configuration) • For backup • For greppability • For bulk replacement

Slide 27

Slide 27 text

Backup Pattern: Point • Sync Interval • If long, it may overwrite the actual configuration

Slide 28

Slide 28 text

Backup Pattern: Example • Datadog Dashboard • Datadog Monitor • Jenkins Configuration (SCM Sync Plugin)

Slide 29

Slide 29 text

Datadog Dashboard

Slide 30

Slide 30 text

Let’s Read http://shop.oreilly.com/product/0636920294382.do

Slide 31

Slide 31 text

Special Thanks • @suzuki-shunsuke • To lead splitting Terraform state • To improve CI/CD pipeline • SRE graduates • To introduce of Infrastructure as Code • To build workflow with maintainability

Slide 32

Slide 32 text

Happy (Infrastructure as) Coding

Slide 33

Slide 33 text

Thank You! chaspy chaspy_ Site Reliability Engineer at Quipper Takeshi Kondo Terraform-jp