Infra

Overview

Infra projects creates two environments (test & prod) using pulumi

Each environment has sql server database, app insights, blob storage and app service.

This project also creates an azure dev ops agent vm which its ip is whitlisted in sql server's firewall rules so it can run migrations against database in every release we made.

Getting started:

1- Create three resource groups (td-test, td-prod, td-cd) using azure cli:

az group create --name td-test --location eastus

az group create --name td-prod --location eastus

az group create --name td-cd --location eastus

Notes:

  • td stands for todo, you can replace it with your own.

  • td-cd resource group contains azure dev ops vm agent related resources.

  • You can use any location supported by azure cloud (run az account list-locations -o table to see full list of locations)

2- Create three service principals for test, prod and cd using followings:

# Create service principal that manage test resource group resources:
az ad sp create-for-rbac -n "td-test" --role Contributor --scopes /subscriptions/{subscriptionId}/resourceGroups/td-test

# Create service principal that manage prod resource group resources:
az ad sp create-for-rbac -n "td-prod" --role Contributor --scopes /subscriptions/{subscriptionId}/resourceGroups/td-prod

# Create service principal that manage cd resource group resources:
az ad sp create-for-rbac -n "td-cd" --role Contributor --scopes /subscriptions/{subscriptionId}/resourceGroups/td-cd

Notes:

  • Replace {subscriptionId} with your own subscription id

  • Running az ad sp will return a json like response which contains appIdl, password and tenant. Store them somewhere safe.

3- Create stacks folder first, then create test, prod and cd folders in stacks folder.

4- Create three different passwords for three pulumi stacks (cd, test, prod) and store them somewhere safe.

5- Set cd stack's password in environment variables:

Windows's cmd sample:

Windows PowerShell sample:

6- Run followings to create cd stack:

7- Provide valid configs and secrets for the first time for cd:

8- Create azure resources using:

9- Run steps (5 to 8) for test & prod but with different configs:

10- Commit / Push changes in stacks folder to the source controller.

Last updated