/IaC-example

examples of using terraform for multi cloud IaC

Primary LanguageHCL

IaC-example

Azure examples of using terraform for multi cloud IaC

This repository contains terraform code for Azure Cloud with Azure Provider to create:

  • Azure ML Studio workspace
  • Storage Account with
    • Blob Storage
    • File Share
  • Azure ML Datastore (Azure Blobstore)

Install terraform on MacOSX

brew update
brew install terraform
brew upgrade
brew update && brew upgrade terraform && brew cleanup terraform
brew cleanup --dry-run
# brew cleanup -n
brew cleanup

Setting up Terraform project

.tfstate file holds all the configurations of the cloud infrastructure that has been created. It should never be uploaded to the git repository

.gitignore the .tfstate

Reference

Install terraform on Mac

brew list terraform
brew install terraform
brew upgrade terraform

Reference:

Install Azure CLI on Mac

brew update && brew install azure-cli
az login

Reference:

init terraform

# init terraform state
terraform init
# plan the change shall be made to your cloud resources
terraform plan
# executed planed changes defined by HCL 
terraform apply

Apply terraform

terraform will take the variables from either terraform.tfvars or .auto.tfvars

Otherwise, we need to define the .tfvars file during the terraform apply.

terraform apply -var-file="const.tfvars"

Visualize your terraform plan

terraform graph -type=plan | dot -Tpng -o graph.png

Upgrade to new provider version

terraform init -upgrade

Destroy

terraform plan -destroy
terraform apply -destroy

Terraform Modules

Learning Source