Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$...

57
Terraform Earth Secure Infrastructure for Developers Chase Evans

Transcript of Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$...

Page 1: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Terraform EarthSecure Infrastructure for Developers

Chase Evans

Page 2: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Timeline

1. Where we were before May

2. Where we are today

3. Where we are going

Page 3: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Timeline

1. Where we were before May

Page 4: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

● Builds Terraform state files by fetchingremote resources, think `$ terraform refresh`

● Manual and distributed changes easily reconciledwhen AWS is the source of truth

● Looks like HCL

● github.com/coinbase/geoengineer

GeoEngineer

Page 5: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Applying Resources

Page 6: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Terraform Mars

Page 7: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem

Page 8: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem (Bottlenecking)

Page 9: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem (Bottlenecking)

Page 10: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem (Bottlenecking)

Page 11: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem (Business units)

Page 12: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem (Platform vs Operations)

Page 13: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem (Did you remember to pull?)

Page 14: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem (Credential proliferation)

Page 15: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Problem (VPC proliferation)

Page 16: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Timeline

1. Where we were before May

2. Where we are today

Page 17: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Introducing Terraform Earth

Page 18: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Heimdall

● Records PR approvals with MFA

● Provides a clean API

● Not vulnerable to administrative

Github tampering

Page 19: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Terraform Earth

Page 20: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Single Production Deployment

● One deployment makes updates easier

● New VPCs work without deployment

Page 21: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Flow Diagram

Page 22: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Flow Diagram

Page 23: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Why bother locking?

● Concurrent changes are usually safe

● Sometimes multiple PRs pile up and need to

modify a resource in order

Page 24: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Flow Diagram

Page 25: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Why SHAs and not ‘master’?

● Master is just a label and moves frequently

● Code has quorum, not labels

● Something could be merged to the repo between quorum check and clone

Page 26: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Flow Diagram

Page 27: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Handling Failure

● Retry the GeoEngineer apply with backoffAWS rate limits heavilyAWS has failures

● Queue and retry● Replay the webhook using Github administration● Add an endpoint to manually intervene

Page 28: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Handling Failure

Not great solutions, if you have ideas, let me know

Page 29: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Staging Deploys

● Setup a bot with limited privilegesYou can test the flow, without breaking everything

We have a separate repository that defines 1 S3 bucket

● Make a periodic cleaner that cleans up test resourcesWe use lambdas to do this

Page 30: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Timeline

1. Where we were before May

2. Where we are today

3. Where we are going

Page 31: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Team Scaling

Page 32: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Team Scaling

Page 33: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Team Scaling

Page 34: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Resource Configuration Today

Page 35: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Ownership

Page 36: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Ownership

Page 37: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Resource Configuration Today

● project = Project.new(‘infra/heimdall’, aws_accounts)

● project.service_with_elb(‘api’, configuration)

● project.rds_instance(‘db’, configuration)

Page 38: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

What’s Wrong?

● Uses language the Infrastructure team knows

● Developer’s mental model of deploys is not represented

● Too many options, very little opinion

● Code is too flexible

Page 39: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Resource Configuration Tomorrow

name: ‘developers/my-service’services:

- api:load_balanced: trueaccessible_by: [‘developers/my-other-service’]

databases:- postgres:

size: medium

Page 40: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Ownership

Page 41: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Ownership

Page 42: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Future

Page 43: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Design Considerations

● Mono-repo or multi-repo

● Automated workflows (PR bots)

● Exposing the information to outside services

Page 44: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Other Half

● Provisioning and management is now easy

● Operation is not

Page 45: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Account Stewardship Today

Page 46: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Account Stewardship Today

Page 47: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Account Stewardship Tomorrow

Page 48: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Complications

● Managing connectivity between many VPCs is hard

● Like microservices, finding the right domain is difficult

● How much access is enough access?

Page 49: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Team Scaling

Page 50: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Team Scaling

Page 51: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Future

Page 52: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Future

Page 53: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Future

Page 54: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

The Future

Page 55: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Secure Infrastructure for Developers

Or: Infrastructure with Vacation

Page 56: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

We’re Hiring!

careers.coinbase.com

Page 57: Terraform Earth - QCon · Builds Terraform state files by fetching remote resources, think `$ terraform refresh` Manual and distributed changes easily reconciled when AWS is the source

Questions?

[email protected]