Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Infrastructure as Code with Terraforms - Thomas...

Infrastructure as Code with Terraforms - Thomas Nyambati

Modern-day infrastructure has become complex, with ever changing technologies

Avatar for Developer Circles: Nairobi

Developer Circles: Nairobi

September 15, 2017
Tweet

More Decks by Developer Circles: Nairobi

Other Decks in Programming

Transcript

  1. The problem Complexity Modern day infrastructure has become complex, with

    ever changing technologies Flexibility • The infrastructure has to be flexible. • Changes are made more often as the product develops Maintainability ➔ Complex infrastructure can be hard to maintain ➔ Reliant on manual steps ➔ Time consuming
  2. Challenges Create How do we plan and create our infrastructure

    and integrate all the services in a predictable manner? How do we avoid the manual painful process? Update How do we maintain, add or remove services in our infrastructure with little interference and at the same time avoid the painful manual process? Replicate How can we recreate the infrastructure with the same services and performance with little interference ?
  3. Solution Introducing Infrastructure as Code(IaC) This is the process of

    managing and provisioning computing infrastructure (processes, bare-metal servers, virtual servers, etc.) and their configuration through machine-processable definition files, rather than physical hardware configuration or the use of interactive configuration tools - wikipedia
  4. Plan Visualize how your infrastructure will be Create/test Translate your

    plan into code, and test it Version Version your changes using version control systems (git) Provision Build your actual infrastructure Modify Add or remove services from your infrastructure
  5. What do we gain? 1. Flexibility 2. Predictability 3. Backup

    plan 4. Collaboration 5. Efficiency 6. Time
  6. IaC with Terraform What is terraform - It is an

    open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned. - Terraform enables you to safely and predictably create, change, and improve production infrastructure.
  7. Benefits of using Terraform - Collaborate and share - Evolve

    your infrastructure - Automation friendly - Versioning
  8. Providers This are plugins that enables us to communicate with

    service providers API A provider is responsible for understanding API interactions and exposing resources. Example # Configure the Heroku provider provider "heroku" { email = "[email protected]" api_key = "${var.heroku_api_key}" } Find list of providers here
  9. Resources This act as functions we can use to provision

    specific Infrastructure resources Example resource "heroku_app" "app" { }
  10. Variables This are temporary containers that hold specific data we

    need to use across our scripts Define a variable variable "heroku_api_key" {} Usage provider "heroku" { email = "[email protected]" api_key = "${var.heroku_api_key}" }
  11. Modules Modules in Terraform are self-contained packages of Terraform configurations

    that are managed as a group. Modules are used to create reusable components in Terraform as well as for basic code organization. Usage module "consul" { source = "github.com/hashicorp/consul/terraform/aws" servers = 3 } Find how to create modules here
  12. Outputs This is configuration data returned back from our resources

    that we might need to use in our scripts Define output output "child_memory" { value = "${module.child.received}" }