In this hands-on workshop, we'll explore how to deploy resources to azure using terraform. First we'll peek into the basics of terraform (HCL language, CLI, providers, provisioners, modules, plans, state files etc).
Then in our hand-on exercise, we'll author terraform scripts to deploy virtual networks, virtual machines and app services to azure. Finally we'll walk through some azure tooling & integrations for terraform (azure cloud shell, hosted images in azure devops, azure marketplace images, VSCode extensions etc).
Author: Mithun Shanbhag
4. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
Terminology
1. Providersrepresent acloud provider (e.g. azurerm,aws) oralocal provider (e.g. tls).
1. Aprovider offers multiple resources & datasources.
2. Resources can be invoked tocreate/update infrastructure locally oron the cloud.
3. Data Sources are“read-only”resources.
4. Scripts/configuration areTerraform (.tf) script files in HCL language.
5. Modules arereusable libraries that allow creation of complex resources.
6. Provisioners areused toexecute scripts on a local orremote machine.
7. State is representation ofthe infrastructure created/updated byterraform.
1. By default state is stored in a local file (terraform.tfstate) but can alsobe stored in a remote backend.
5. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
Providers
1. Terraformproviders forAzure
1. AzureRM provider
2. AzureAD provider
3. AzureStack provider
2. Authenticate with
1. AzureCLI
2. AzureService Principal
3. AzureManaged Service Identity
3. Other useful providers
1. TLS (create keys, certs, secrets)
2. Null (run provisioners)
3. Local (create local files)
4. Template (create strings from templates)
14. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
Provisioners
1. Configureremote resources over SSH/WinRM connections
2. Commonly used provisioners:
1. file: copy files/directories from local Terraformserver tothe remote
resource
2. local_exec: runcommands on local Terraformserver
3. remote_exec: run commands on remote resource)
3. Generally used with “null_resource” provider(with “trigger”argument)
2.4. With an execution plan, you don’t have to worry about order of destruction, creation, dependencies etc. All that gets figured out by the terraform provider.
??? Explain these meta-arguments
lifecycle
One .tf file vs multiple .tf files
1.2 maps are key-value pairs where keys are strings
1.2. sets are similar to lists, but unique values only
1.3. objects { <KEY> = <TYPE>, <KEY> = <TYPE>, ... }
1.4. tuples [<TYPE>, <TYPE>, ...]
AzureRM backend: How to use without service principal (use valet key)?