Connect to Azure
az login
MS Azure list connections
MBP-di-Omar:terraform apple$ az account list
[
{
"cloudName": "AzureCloud",
"homeTenantId": "***********ed7",
"id": "*************763",
"isDefault": true,
"managedByTenants": [],
"name": "*****",
"state": "Enabled",
"tenantId": "************ed7",
"user": {
"name": "**********",
"type": "user"
}
}
]
init.sh script to post installation
#!/bin/bash
#Installing Docker
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce -y
sudo usermod -a -G docker $USER
sudo systemctl enable docker
sudo systemctl restart docker
sudo docker run --name docker-nginx -p 80:80 nginx:latest
Start and apply Terraform to deploy infrastructure
terraform init
terraform plan -out main.tfplan
terraform apply main.tfplan

Azure list resources on “test” RG
az resource list -g test -o table

Export info
terraform output public_ip_address
terraform output -raw tls_private_key > id_rsa
chmod 600 id_rsa
ssh -i id_rsa azureuser@public_ip

Check if Docker and Nginx are up & running

.. and check on the web browser

List on Azure GUI

Destroy all
terraform plan -destroy -out main.destroy.tfplan
terraform apply main.destroy.tfplan

Terraform Azure regions
https://github.com/claranet/terraform-azurerm-regions/blob/master/REGIONS.md
Download