Repository navigation
Done
Labels
complexity: mediumdependencyfeature: securityrole: DevOps Engineersize: 3ptCan be done in 13-18 hours
Milestone
Description
Dependency
- Product: Setup Azure Hosting for non profits devops#234 (Azure grant provisioned)
Overview
We need Azure identities for this repo's Terraform workflows to log in with, and they have to be made by hand because Terraform can't create the identity it runs as. They're the Azure counterpart of the hand-made devops-security-tf-plan and devops-security-tf-apply IAM roles, and this repo's Terraform then creates incubator's Azure CI identities, as it does on AWS.
Action Items
- Create a resource group
terraform-ciin West US 2, taggedmanaged-by = exempt. It holds only the hand-made identities; anything Terraform creates goes elsewhere. - Create two user-assigned managed identities in it,
devops-security-tf-plananddevops-security-tf-apply, taggedmanaged-by = exempt. Two identities mirror the AWS roles: plan is read-only, apply has write rights. - Add a flexible federated identity credential to each with
az rest(ARM, API version2025-01-31-preview; the CLI and Terraform can't create flexible credentials yet). Both checkclaims['repository_id'] eq '744797221' and claims['repository_owner_id'] eq '11635254', so a deleted-and-recreated repo of the same name, or one transferred out of hackforla, can't log in. Plan addsclaims['sub'] matches 'repo:*'. Apply addsclaims['sub'] eq 'repo:hackforla/devops-security:ref:refs/heads/main', matching the AWS apply role:terraform-apply.yaml's manual trigger applies without a reviewed plan, so apply must only be usable frommain. - Grant Azure roles at subscription scope. Apply: Contributor and Role Based Access Control Administrator, so it can create identities and give them roles. Plan: Reader.
- Grant Microsoft Graph application permissions (needs a Global Administrator). Apply:
AppRoleAssignment.ReadWrite.AllandApplication.Read.All, so it can give incubator's identities their own Graph permissions. Plan:Application.Read.All.AppRoleAssignment.ReadWrite.Alllets apply grant any Graph permission, itself included; that is accepted, the same footing as the AWS apply role'sAdministratorAccess. - Add repository variables (not secrets) on this repo:
AZURE_TENANT_ID,AZURE_SUBSCRIPTION_ID,AZURE_CLIENT_ID_PLAN,AZURE_CLIENT_ID_APPLY. They identify the identities but aren't secret. - Add
terraform/azure-ci-bootstrap.mddescribing everything created here, the exact expressions and grants, and how to recreate it, since none of it is in Terraform. Link it from the README. - Test from a throwaway branch with a temporary workflow that runs on push: one job logs in with
azure/loginas plan and runsaz account show(should pass), another tries to log in as apply (should be refused, because the branch isn'tmain). Delete the branch afterwards; it never becomes a PR. Apply's successful login is proven after the next ticket's PR merges.
Resources/Instructions
- Flexible federated identity credentials
- azure/login with OIDC
- The AWS precedent: Move the Terraform workflows off static AWS credentials onto OIDC #182 created this repo's CI roles by hand, tagged
managed-by = exempt; the reason is recorded at the top ofterraform/aws-gha-oidc-providers.tf. - Get the IDs with
gh api repos/hackforla/devops-security --jq '.id, .owner.id'.
Metadata
Metadata
Assignees
Labels
complexity: mediumdependencyfeature: securityrole: DevOps Engineersize: 3ptCan be done in 13-18 hours
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]Bootstrap the Azure identity for incubator's Terraform CI[/-][+]Bootstrap the Azure identities for devops-security's Terraform CI[/+]Document the hand-made Azure CI identities (#239)
ale210 commentedon Dec 1, 2026
Done. Identities, credentials, roles, Graph grants and repository variables created by hand and verified; login test passed (plan logged in, apply refused from a non-main branch, run); documented in #239.