This guide shows you how to deploy infrastructure using the automated GitHub Actions pipelines available in this repository.
- Overview
- Prerequisites
- Pipeline Steps
- Running the Pipeline
- Choosing the Right Pipeline
- Notes
- Using an Existing Terraform Backend or Resource Groups
This repository provides two main GitHub Actions pipelines for infrastructure deployment:
-
Single-Region: Workflow:
.github/workflows/ci-cd-infra-dev-single-region.yml -
Multi-Region: Workflow:
.github/workflows/ci-cd-infra-dev-multi-region.yml
Use the pipeline that matches your deployment scenario. Each pipeline automatically manages the correct folder paths and deployment steps.
- Manual Step (Step 00: DevOps):
You must run step 00-devops manually before starting the pipeline. This initializes the resource groups, storage, and permissions needed for the rest of the deployment.
- Path:
envs/dev/00-devops/(single- or multi-region as appropriate) - For details on this manual step, see DevOps Setup (Manual Prerequisite).
- Path:
- Pipeline Environment Variables: After running step 00-devops, set all required environment variables and GitHub secrets using the outputs. See Setup-environment.md for details.
-
Environment Setup
- Make sure all required environment variables and secrets in GitHub are set using the outputs from step 00. See Setup-environment.md.
-
Base Infrastructure (Pipeline)
- Deploys core networking, MongoDB Atlas resources, observability function infrastructure, and, if multi-region, configures VNet peering.
- For details on observability function and function app setup, see Mongo Atlas Metrics App docs.
- Important: You need to run this step twice:
- First run: Set
TF_VAR_open_access=trueto allow Key Vault creation, initial secret injection and to deploy the Azure Function's code. - Second run: Set
TF_VAR_open_access=falseto restrict Key Vault and Azure Function network access according to SFI/compliance requirements.
- First run: Set
-
Application (Optional)
- Deploys test application infrastructure (App Service Plan, subnet, Azure Web App).
- Make sure to set any additional variables mentioned in Setup-environment.md, such as
TF_VAR_key_name_infra_tfstate.
-
Testing Connectivity (Optional)
- You can deploy a web app to test database connectivity. See Test_DB_connection_steps.md for more information.
- Note: The variables
FUNCTION_APP_NAME,FUNCTIONAPP_RG_NAME,APP_WEBAPPS, andAPP_WEBAPPS_RG_NAMESmust be set after running and applying the Application step, as their values are determined from the outputs of that step.
Note: The pipeline does not automatically apply all changes. It will pause at the apply step and create a GitHub issue for manual approval by your designated approvers.
- Set the
approversparameter in ci-cd-infra-base.yml. - See Manual Approval Action documentation for details.
- Go to the Actions tab in your GitHub repository.
- Select the workflow matching your region type:
- Single-Region:
CI - CD Infra Dev (Single-Region) - Multi-Region:
CI - CD Infra Dev (Multi-Region) - App Code Deployment:
Deploy Applications' code
- Single-Region:
- Click Run workflow.
- Choose the steps as needed via checkboxes (plan/apply, infra/app, etc.).
- Wait for the manual approval step if changes are detected.
Deploy Applications' code includes:
- Deploy MongoAtlasMetrics Function App: (default: enabled, requires infrastructure deployed)
- Deploy Test DB Connection App: (optional, requires infra & app infrastructure deployed)
- Single-Region:
.github/workflows/ci-cd-infra-dev-single-region.yml— For deployments usingtemplates/single-region/envs/dev/ - Multi-Region:
.github/workflows/ci-cd-infra-dev-multi-region.yml— For deployments usingtemplates/multi-region/envs/dev/ - App Code:
.github/workflows/ci-cd-application.yml— For deploying the MongoAtlasMetrics Function App or Test DB Connection App
- If you need to re-run a pipeline, make sure all manual prerequisites (such as API key creation) are up to date.
- Do not run both the single-region and multi-region pipelines at the same time unless you are certain your Terraform state references are separate and correct.
For instructions on using an existing Terraform backend or existing resource groups, see Using an Existing Backend or Resource Groups.