Skip to content

Infrastructure Provisioning

Once the terrafrom bootstrapping process is complete, all Azure resources from then on are provisioned and managed using the terraform-wrapper.sh bash script, which accepts environment and command as arguments.

  • Valid choices for environment are development, nonproduction and production.
  • Valid choices for command are plan and apply.

You can either run the script locally for quicker feedback and validation on your terraform changes or simply push your changes to a GitHub feature branch and open a pull request to trigger the GitHub Actions continuous integration workflow found in each <microservice-infra> GitHub repository.

Validate Terraform Changes Locally

  1. Login to Azure and ensure your local configuration points to the development environment.

    az login
    az account set --subscription reg1-development-001
    

  2. Clone the setup-terraform-wrapper GitHub repository.

  3. Run the following commands to plan and apply your terraform changes.

    cd setup-terraform-wrapper
    ./terraform-wrapper.sh development plan
    ./terraform-wrapper.sh development appply
    

  4. You can also add the script to an executable path e.g., /usr/local/bin on macOS, by creating a symbolic link (OPTIONAL).

    ln -s setup-terraform-wrapper/terraform-wrapper.sh /usr/local/bin/terraform-wrapper
    terraform-wrapper development plan
    terraform-wrapper development apply
    

Validate Terraform Changes In GitHub Actions Workflows

The terraform code and configuration in each <microservice-infra> GitHub repository is applied to the Development, Non Production and Production environments in the following order:

  1. When a terraform change is committed and a new pull request is created against a <microservice-infra> GitHub repository, it triggers Terraform CI Into Dev reusable workflow which performs unit and security tests before planning and applying the terraform change to the Development environment.
  2. When the terraform change passes all the tests and the pull request is merged, it triggers the Terraform CD Into NonProd or Prod reusable workflow which automatically deploys the change into the Non Production environment.
  3. Lastly, the change is manually promoted to the Production environment on an agreed change window.

Note

All reusable GitHub workflows can be found in the azure-microservice-workflows GitHub repository. Additionaly, the repository is not tagged at present therefore all the <microservice-infra> GitHub repositories point to the main branch to pull the latest changes e.g. user-infra.