Slide 1

Slide 1 text

Copyright © 2019 HashiCorp Everything as Code with Terraform All Things Open | October 14, 2019

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

“I can’t stand using this interface to paste all of these code snippets.”

Slide 5

Slide 5 text

(Actually 2 years, ~20 blogs, and slightly more wisdom later…)

Slide 6

Slide 6 text

“Oh, I can build a Terraform provider that reads Markdown and sends it up to Medium.”

Slide 7

Slide 7 text

“Blog-as-Code”

Slide 8

Slide 8 text

Agenda Infrastructure-as-Code Terraforming the Datacenter Extending Terraform Writing a Provider Everything-as-Code Or Get Close 8

Slide 9

Slide 9 text

hashi.co/2019-ato

Slide 10

Slide 10 text

Infrastructure-as-Code Terraforming the Datacenter 10

Slide 11

Slide 11 text

Infrastructure-as-Code Goals ▪ Unify the view of resources ▪ Support the modern data center (IaaS, PaaS, SaaS) ▪ Expose a way for individuals and teams to safely and predictably change infrastructure ▪ Provide a workflow that is technology agnostic ▪ Manage anything with an API 11

Slide 12

Slide 12 text

“I don’t know how to code. But I do want to automate how I configure my infrastructure.” - An Infrastructure Engineer Who Started Using Public Cloud 12

Slide 13

Slide 13 text

“It was hard enough for me to learn infrastructure terms but writing code for it too? Difficult.” - A Developer Who Started Using Public Cloud 13

Slide 14

Slide 14 text

Terraform HashiCorp Configuration Language CODE EDITOR resource "google_compute_instance" "default" { name = "test" machine_type = "n1-standard-1" zone = "us-central1-a" tags = ["foo", "bar"] boot_disk { initialize_params { image = "debian-cloud/debian-9" } } // Local SSD disk scratch_disk { } network_interface { network = "default" access_config { // Ephemeral IP } 14

Slide 15

Slide 15 text

Extensible & Idempotent CODE EDITOR resource "datadog_monitor" "foo" { name = "Name for monitor foo" type = "metric alert" message = "Monitor triggered. Notify: @hipchat- channel" escalation_message = "Escalation message @pagerduty" query = "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 4" thresholds = { ok = 0 warning = 2 warning_recovery = 1 critical = 4 critical_recovery = 3 } notify_no_data = false renotify_interval = 60 15

Slide 16

Slide 16 text

TERMINAL + resource will be created
 - resource will be destroyed
 ~ resource will be updated in-place
 -/+ resources will be destroyed and re-created 16

Slide 17

Slide 17 text

Infrastructure-as-Code github.com/joatmon08/2019-demo-ato

Slide 18

Slide 18 text

18 terraform.io/docs/providers/

Slide 19

Slide 19 text

Extending Terraform Writing a Provider 19

Slide 20

Slide 20 text

terraform.io/docs/extend/how-terraform-works.html

Slide 21

Slide 21 text

Let’s build a provider. github.com/joatmon08/2019-demo-ato

Slide 22

Slide 22 text

Useful Resources ▪ Writing Custom Providers - official documentation ▪ Plugin SDK - now officially separated from core ▪ Creating a Terraform Provider for Just About Anything by Eddie Zanewski ▪ Check out other providers like AWS or GCP!

Slide 23

Slide 23 text

Everything-as-Code Or Get Close 23

Slide 24

Slide 24 text

Terraform Provider for Medium github.com/joatmon08/ terraform-provider- medium CODE EDITOR resource "medium_image" "draft" { file_path = "./images/draft.png" content_type = "image/png" } resource "medium_post" "my-post" { title = "Writing a Terraform Medium Provider" content = templatefile("./ content.md", { image_url = medium_image.draft.url }) content_format = "markdown" publish_status = "draft" tags = ["terraform", "medium", "automation"] }

Slide 25

Slide 25 text

Tips for Building _______-as-Code ▪ Non-ideal upstream APIs – Read-only provider – Write your own client ▪ Testing – Express functionality in acceptance tests – Examine interface changes with contract tests

Slide 26

Slide 26 text

Alerts-as-Code? Datadog Grafana PagerDuty To Do-as-Code? Google Calendar G Suite Todoist
 (link) Life-as-Code? Meetup 
 (community-as-code)
 Domino’s Pizza
 (pizza-as-code)
 Pokémon
 (catch 'em-all-as-code)

Slide 27

Slide 27 text

“I like your blog but we don’t speak much English. Do you have translations?” 27

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Translated Blog-as-Code github.com/joatmon08/2019-demo-ato

Slide 30

Slide 30 text

“Doing Better”-through-Code 30

Slide 31

Slide 31 text

speakerdeck.com/joatmon08/everything-as-code-with-terraform Rosemary Wang (she/her) Developer Advocate at HashiCorp @joatmon08 joatmon08 linkedin.com/in/rosemarywang/ 31