Skip to content

Latest commit

 

History

History
52 lines (27 loc) · 2.49 KB

02-what-is-cloud_terraform.md

File metadata and controls

52 lines (27 loc) · 2.49 KB

Introduction to terraform

The goal: show main terraform commands and how to use templates from this repository

  1. How to run the commands

    The repository supports VSCode remote containers. .devcontainer directory contains a ready-to-go profile and dockerfile with required dependencies to run all the samples.

    You can run all the commands:

    • on your own environment, then you have to install all the used tools (terraform, az-cli, az-func, etc)
    • inside VSCode Remote Container, then you have to install docker and VSCode extention Remote Development.
  2. What is terraform

    Terraform is software which helps to describe infrastructure as code and manage it's lifecycle: plan, create, delete. If you are not familiar with terraform, after going through this demo check the complete getting-started tutorial.

    terraform transforms human-readable configuration into a state file, which applies then to external resources (e.g. Azure Cloud):

    terraform

  3. Basic commands

    1. Login to your Azure Cloud: az login --use-device-code and set your default subscription: az account set -s SUBSRIPTION_ID.

    2. Navigate to directory with terraform configuration: cd src/terraform/02-what-is-cloud

    3. Initialize terraform: terraform init

    4. Create terraform.tfvars file. This file contains your unique properties for the rest of terraform configuration. You can use a sample generator script: ../generate_tfvars.sh

    5. Plan: terraform plan -out whatiscloud.tfplan

    6. If you are happy with proposed plan, deploy the infrastructure: terraform apply "whatiscloud.tfplan". Browse resources in Azure portal after creation.

    7. Check terraform state file

      Highlight that state has sensitive data

    8. Find created resources in Azure Portal

    9. Change Storage account required TLS version and apply changes.

      Add min_tls_version = "TLS1_2" at line 21 in file src/terraform/02-what-is-cloud

      Alternatively to running plan and apply in separate commands, it is possible to execute just terraform apply

      Check the resource state at Azure Portal.

    10. Try changing the prefix variable and then plan: terraform plan

    11. Clean up created resources: terraform destroy