Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Terraform Q&A - HashiCorp User Group Oslo


Published on

HashiCorp User Group Oslo - initial commit meetup about Terraform by Anton Babenko - 20.11.2017

Published in: Software
  • Be the first to comment

Terraform Q&A - HashiCorp User Group Oslo

  1. 1. HashiCorp User Group Oslo 20.11.2017
  2. 2. Food sponsor: Agenda - initial commit 1. About this user group 2. Terraform questions & problems 3. Terraform Q&A Want to be a speaker? Send an email -
  3. 3. About this user group This HashiCorp User Group Oslo is the place where interested people gather once every couple months to learn from each other  about HashiCorp products— what we do, how we do it, and how can we do it differently. While I generally strive to make such meetups interesting for the participants, I am often against the repetitive talks which can be found online easily. Latest editition: 20.11.2017 Anton Babenko, CEO at Betajob Keywords: All-5 AWS certified, DevOps, infrastructure as code, automation, open-source, community member and events organiser, Terraform modules, solution architectures, serverless. About me
  4. 4. Featuring... Read also -
  5. 5. Featuring... Write, Plan, and Create Infrastructure as Code
  6. 6. Terraform 101 ( provider "aws" { region = "eu-west-1" } resource "random_pet" "bucket" {} resource "aws_s3_bucket" "app" { bucket = "hi-${random_pet .bucket. id}" website { index_document = "index.html" } } data "template_file" "index" { template = "${file("index.html")}" vars { BUCKET = "${aws_s3_bucket .app.website_endpoint }" } } resource "aws_s3_bucket_object" "object" { bucket = "${aws_s3_bucket}" key = "index.html" content = "${data. template_file .index.rendered }" etag = "${md5(data. template_file .index.rendered )}" content_type = "text/html" acl = "public-read" } output "app_website_endpoint" { value = "${aws_s3_bucket .app.website_endpoint }" } index.html can access: ${BUCKET} $ terraform init $ terraform plan $ terraform apply Apply complete! Resources: 3 added, 0 changed, 0 destroyed. Outputs: app_website_endpoint = hi-feasible-basilisk.s3-website-eu-west-1.a
  7. 7. Frequent Terraform Questions (FTQ)
  8. 8. Why Terraform and not AWS CloudFormation/Azure ARM templates/Google Cloud Deployment Manager? Terraform manages 70+ providers, has easier syntax (HCL), has native support for modules and remote states, has team-work features. Terraform is an open-source project (640 - AWS provider, 1100 - core). rm-and-packer-training-material
  9. 9. Tord P.: What is the point of using these tools if you’re running AWS only, e.g. isn’t Terraform just a an unnecessary abstraction, why not stick to CloudFormation? Terraform manages 70+ providers, has easier syntax (HCL), has native support for modules and remote states, has team-work features. Terraform is an open-source project. Abstractions (primitives and modules) are necessary and easily available (Terraform Registry).
  10. 10. What are the most common tools/solutions out there? ● Terraform Module Registry to discover modules for common infrastructure configurations for any provider - (I maintain verified AWS modules there) ● Thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules - ● Terraform linter for detecting errors that can not be detected by `terraform plan` - ● Terraform version manager - This list is much longer, really…
  11. 11. How to handle secrets in Terraform? 1. Can you accept secrets to be saved in state file in plaintext? Probably not. a. AWS IAM password & access secret keys - use PGP as b. AWS RDS - set dummy password and change after DB is created c. AWS RDS - use iam_database_authentication_enabled = true d. EC2 instance user-data + AWS KMS 2. Other options: a. Secure remote state location (S3 bucket policy, KMS key)
  12. 12. How to get started? 1. Install and getting started - 2. Get infrastructure modules from Terraform Registry. For example, AWS modules - 3. Follow instructions in, check examples, open issues and pull requests.
  13. 13. Frequent Terraform Problems (FTP)
  14. 14. Upgraded Terraform version, and there is a breaking bug, so I want to rollback, but I can’t because state file has been upgraded already. ● State file should be versioned (!), download previous version of state file, run “terraform state push old_version.tfstate” ● Lock terraform version, lock module and providers version (new in 0.11) ● Read upgrade guides and files: ○ ○ ○
  15. 15. What is your Terraform question or problem? PS: Maybe something about testing? Versioning? Code structure? Working as a team? CI/CD? Automation? Integration with other tools? ? Code generation? Missing tools/features? Syntax sugar (features and types of variables)? How to contribute?
  16. 16. Thanks! rm-and-packer-training-material - "Add Terraform template for cluster creation”