You need one Azure subscription you can fully manage.
And you need to get credentials after setting up system accounts for provisioning as described below.
You should create an Azure service principal that added follows roles.
Contributor
You need create the .env
file as follows.
CURRENT_ENV_NAME=production
PROJECT_UNIQUE_ID=YOUR_UNIQUE_ID_AS_A_RESOURCE_PREFIX
AZURE_DEFAULT_LOCATION="Central US"
ARM_SUBSCRIPTION_ID=********
ARM_CLIENT_ID=********
ARM_CLIENT_SECRET=********
ARM_TENANT_ID=********
echo TF_VAR_allowed_ipaddr_list='["'$(curl -sL ifconfig.io)'/32"]' >> .env
If you are using Linux, you should add UID and GID to the .env
file as follows.
test $(uname -s) = 'Linux' && echo "UID=$(id -u)\nGID=$(id -g)" >> .env
Now you can make provisioning as follows.
docker compose up --detach && docker compose logs --follow
^c
docker compose exec provisioning terraform plan
docker compose exec provisioning terraform fmt -recursive
docker compose exec provisioning terraform apply -auto-approve
"Host" request header | HTTP Status Code | "X-ServerName" response header |
---|---|---|
-- | 404 | -- |
blue.example.com | 200 | blue.example.com |
green.example.com | 200 | green.example.com |
❯ curl -sI $AppGwPubIp | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 404 Not Found
Server: Microsoft-Azure-Application-Gateway/v2
❯ curl -sI $AppGwPubIp -H 'Host: blue.example.com' | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
X-ServerName: blue.example.com
❯ curl -sI $AppGwPubIp -H 'Host: green.example.com' | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
X-ServerName: green.example.com
"Host" request header | HTTP Status Code | "X-ServerName" response header |
---|---|---|
-- | 200 | -- |
blue.example.com | 200 | blue.example.com |
green.example.com | 200 | -- |
❯ curl -sI $VMBluePubIp | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
❯ curl -sI $VMBluePubIp -H 'Host: blue.example.com' | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
X-ServerName: blue.example.com
❯ curl -sI $VMBluePubIp -H 'Host: green.example.com' | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
"Host" request header | HTTP Status Code | "X-ServerName" response header |
---|---|---|
-- | 200 | -- |
blue.example.com | 200 | -- |
green.example.com | 200 | green.example.com |
❯ curl -sI $VMGreenPubIp | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
❯ curl -sI $VMGreenPubIp -H 'Host: blue.example.com' | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
❯ curl -sI $VMGreenPubIp -H 'Host: green.example.com' | grep -E '^(HTTP/|Server|X-ServerName):?'
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
X-ServerName: green.example.com