terraform at adobe

26
Terraform at Adobe Kelvin Jasperson

Upload: kelvin-jasperson

Post on 07-Feb-2017

130 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Terraform at Adobe

Terraform at AdobeKelvin Jasperson

Page 2: Terraform at Adobe

Introduction

2

Systems Engineer @ Adobe Audience Manager (AAM)Been with Adobe for 18 months

AAM was acquired by Adobe in 2011, and is 100% in AWS

Twitter- @zxjinn

Page 3: Terraform at Adobe

HashiCorp

3

Page 4: Terraform at Adobe

Raise your hands• Who knows what Terraform is?• Who uses Terraform?• … in production?

4

Page 5: Terraform at Adobe

Terraform• Infrastructure as code• Supports many providers• AWS• Azure• Digital Ocean• Google Cloud• Heroku• OpenStack• VMware vSphere/vCloud Director• others…

5

Page 6: Terraform at Adobe

Why Terraform?• Fun to write• Easy to extend with modules• Shows the execution plan (no-op)• State stored in a committable file

6

Page 7: Terraform at Adobe

Basic Terraform Example

Page 8: Terraform at Adobe

Basic Terraform Example $ cat main.tfresource "aws_instance" "app" { ami = "ami-d1f482b1" count = 5 instance_type = "t2.micro"}$ terraform plan+ aws_instance.app.0...+ aws_instance.app.1...$ terraform applyaws_instance.app.0: Creating...Apply complete! Resources: 5 added, 0 changed, 0 destroyed.$

8

Page 9: Terraform at Adobe

It worked! Parallel, takes ~1 min

9

Page 10: Terraform at Adobe

Basic Terraform Destroy$ terraform destroyDo you really want to destroy? Terraform will delete all your managed infrastructure. There is no undo. Only 'yes' will be accepted to confirm. Enter a value:

10

yes

aws_instance.app.0: Destroying...Apply complete! Resources: 0 added, 0 changed, 5 destroyed.$

Page 11: Terraform at Adobe

It worked! Parallel, takes ~1 min

11

Page 12: Terraform at Adobe

More than just EC2 instances• S3- Simple Storage Service• CloudFormation• VPC- Virtual Private Cloud• SQS- Simple Queue Service• Route53- Hosted DNS• RDS- Relational Database Service• IAM- Identity and Access Management• ECS- EC2 Container Service• others…

12

Page 13: Terraform at Adobe

Modules, Compositions, and Clusters

13

Page 14: Terraform at Adobe

Modules• Self-contained reusable code• Behavior changes based on inputs• Terraform code

14

Clusters

Compositions

Modules • Foundation

Page 15: Terraform at Adobe

Compositions• Pre-defined collections of modules• Passes parameters to many modules• Terraform + Jinja

15

Clusters

Compositions

• Frame

Modules • Foundation

Page 16: Terraform at Adobe

Clusters• Passes params to one composition• Ultimate source of truth• YAML

16

Clusters • Blueprint

Compositions

• Frame

Modules • Foundation

Page 17: Terraform at Adobe

For example• Module• VPC module- NAT and Bastion instances, security groups, etc• App1 module- App1 Instances, SQS queues, S3 buckets, subnets• DB1 module- RDS instances, security groups• Admin module- Instances- config management, monitoring, etc

• Composition• Edge composition- VPC, App1, DB1, Admin• DataProcessing composition- VPC, App2, DB2, Admin• Delivery composition- VPC, App3, Admin

17

Page 18: Terraform at Adobe

Analogous to modern Puppet design• Terraform Modules = Puppet Modules• Compositions = Roles and Profiles• Clusters = ENC and Hiera

18

Page 19: Terraform at Adobe

Ops wrapper• Reads cluster YAML variables• Reads composition (.tf.jijna2), writes Terraform (.tf) files with cluster

variables injected

19

Page 20: Terraform at Adobe

Demo!

20

Page 21: Terraform at Adobe

The Future• Jenkins runs Terraform and commits statefile• Web interface to generate cluster YAML files for self service• Pending discussion: ops wrapper generates Terraform JSON instead of

parsing jinja

21

Page 22: Terraform at Adobe

Lessons Learned, Best Practices• A springboard for Terraform (ops wrapper for us) is invaluable• Terraform HCL + Jinja templates are easier to write and read than

Terraform JSON• Make 1 cluster = 1 vpc = 1 environment = 1 purpose• Reproducible environments• Separated Terraform statefiles per cluster

• Version user data in a map variable• Symlink shared Terraform files in modules• Separate “common” infrastructure like- S3 buckets, SQS, IAM to its own

cluster

22

Page 23: Terraform at Adobe

Don’t• Get impatient with Terraform• Go in guns blazing and use it in production on day 1• Skip reading the Terraform docs

23

Page 24: Terraform at Adobe

Woohoooo!• 85% of our production infrastructure is managed with Terraform!

24

Page 25: Terraform at Adobe

Questions?

25

Page 26: Terraform at Adobe