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

Terraform in Azure

Terraform in Azure

grigoresc

April 17, 2022
Tweet

More Decks by grigoresc

Other Decks in Programming

Transcript

  1. INTRO ABOUT THE SPEAKER ▸ Ciprian has been in the

    IT fi eld for quite some time and got accustomed to various web technologies. ▸ Currently he mainly develops .net web apps for the Azure cloud. ▸ He is into devops culture.
  2. INTRO KEYWORDS ▸ Devops ▸ Provisioning ▸ Infrastructure as Code

    - IaC ▸ Terraform ▸ Terraform in Azure ▸ Prizes
  3. INTRO IAC - DEFINITION ▸ “Infrastructure as Code (IaC) is

    the management of infrastructure (networks, virtual machines, load balancers, and connection topology) in a descriptive model, using the same versioning as DevOps team uses for source code. Like the principle that the same source code generates the same binary, an IaC model generates the same environment every time it is applied. IaC is a key DevOps practice and is used in conjunction with continuous delivery.” (Microsoft)
  4. INTRO SOLUTIONS ▸ Ansible ▸ Puppet ▸ Chef ▸ Terraform

    ▸ ARM Templates (Azure) ▸ CloudFormation (AWS)
  5. TERRAFORM BIG PICTURE ▸ Con fi guration fi les for

    modelling infrastructure - declarative and not procedural ▸ CLI ▸ Generic usage - language/tool is cloud agnostic ▸ Providers - AWS, Azure, GCP, etc
  6. TERRAFORM CONFIGURATION FILES ▸ Resources ▸ Variables/Out ▸ Data (or

    references) ▸ Modules ▸ .tf fi les ▸ Multiple fi les ▸ HCL syntax (also json) ▸ “depends on”
  7. TERRAFORM STATE ▸ Local disk, by default ▸ Remote (“Backend”)

    ▸ May contains credentials, so pay attention ▸ When “apply” fails somewhere in the middle, the successful changes are stored into the state
  8. TERRAFORM SCENARIO 2 - IMPORT EXISTING ENVIRONMENT ▸ Write con

    fi gurations ▸ Import command ▸ Import is made for each resource ▸ Apply will create new env
  9. TERRAFORM SCENARIO 3 - USE EXISTING RESOURCES AS REFERENCE ONLY

    ▸ Write con fi gurations ▸ Use “data” instead of “resource” ▸ e.g. we may need reference to an existing Service Bus ▸ The “Service Bus” maybe be part of other IaC..
  10. TERRAFORM SCENARIO 4 - REUSE CONFIGURATIONS ▸ Write modules -

    e.g. called “backend”, “frontend” ▸ Write con fi gurations and reuse modules ▸ Maybe have 3 con fi gurations - qa/acp/prod
  11. TERRAFORM DEMOS ▸ Scenario 1 - create a new infra

    setup; adjust details ▸ Scenario 2 - import existing infra ▸ Scenario 3 - adjust infra setup - use external resources
  12. TERRAFORM IN AZURE ▸ For IaaS (VMs/VNets/LBs), Paas (Azure functions,

    App Services), AKS (Azure Kubernetes Service) ▸ Alternative to ARM templates ▸ Available in CloudShell ▸ Documentation available on MS docs
  13. TERRAFORM AZURE DEVOPS - PART OF A CI/CD PIPELINE ▸

    Build tasks available in MarketPlace
  14. TERRAFORM DEMO - SHOW A CI/CD PIPELINE ▸ Purpose -

    show how terraform tasks can be used in “Azure Devops” pipelines
  15. END TAKEAWAYS ▸ IaC - helps you manage large infrastructure

    easily; already mainstream concept ▸ Terraform - a sample of what we expect from IaC (code/test/deploy infrastructure) ▸ Microsoft world - we can use non-Microsoft tools for a better job
  16. Q&A