- Install the az CLI
- Request access to resource groups from admins (PO or tech lead)
- Install terraform CLI
Azure provides us with 2 resource groups per project:
- A staging environment denoted by
test
- A non-prod final environment for the live app
- Azure is not in
prod
status so officially we have to call this non-prod for live apps
- Azure is not in
- Ensure the setup/ terraform was initialized correctly
az login
- Run the following to set the environment:
export TF_VAR_azure_tenant_id=$(az account show --query tenantId --output tsv)
export TF_VAR_azure_subscription_id=$(az account show --query id --output tsv)
- WHILE IN
./staging/
or./live/
runterraform init
which downloads any plugins you might need and checks the backend state connection terraform plan
does a diff between theremote state
vsyour local tf code
terraform apply
applies the detected diff ofplan
but note that a successful plan does not guarantee a successful apply - runtime errors can occur!
- First, ensure the remote tf state storage has been correctly deployed in the resource group so that infra changes are correctly tracked - refer to Azure Setup
- After following the above terraform instructions: in order for the
openshift cronjob
to succeed with its restore process we need to manually seed some data into the deployed azure databases - Run
pg_dumpall --roles-only -U postgres > /tmp/roles_super.sql
in the source database and add any needed roles (mds
,postgres
,nris
) to the azure database by running the resulting sql. We need to do this manually since our postgres version is 9.6 there's a bug where roles are not included in pg_dumps and so they're not included in our backups - we need to add them separately - Run the sql pertaining to roles
mds
,postgres
andnris
on the azure database while connected topostgres
. you can connect to an azure database using your preferred DB tool. Just use the credentials exemplified in theConnection Settings
page of the resource. Ensure yourclient IP
has been added to the firewall ruleset or you will get assl error
upon connection. - With the
required roles
seeded, thesilver ip address allowed
, the restore process in the cronjob can now succeed - The above steps are stored in an
azure-reporting
secret in the namespace for manual purposes
If infrastructure is not version controlled as code then it does not exist.
That being said, we are human and do want to support an organic/exploratory development process that appeals to this best practice. In the event infrastructure is created via the UI / CLI, make sure you import the state to the remote backend and version control matching terraform configurations