Skip to content

Add Azure to devops-security's Terraform and create incubator's CI identities #238

Done

Description

@ale210

Dependency

Overview

We need this repo's Terraform to manage Azure as well as AWS, and to create the Azure identities hackforla/incubator's Terraform workflows log in with. It's the Azure counterpart of incubator-tf-plan and incubator-tf-apply in terraform/aws-gha-oidc-providers.tf.

Action Items

  • Add azurerm, azapi and azuread to required_providers in terraform/backend.tf, with pinned versions, logging in with OIDC from the environment the workflow sets. Set default_tags = { managed-by = "terraform-devops-security" } on azapi, and use a shared tags local for azurerm resources.
  • Add an azure/login step (OIDC) to the plan and apply workflows, as the plan and apply identities from Bootstrap the Azure identities for devops-security's Terraform CI #237, using this repo's AZURE_* variables. The state stays in S3.
  • Create a resource group incubator-ci in West US 2 for incubator's identities, separate from the hand-made terraform-ci.
  • Create user-assigned identities incubator-tf-plan and incubator-tf-apply in it.
  • Add a flexible federated credential to each with azapi_resource (Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials@2025-01-31-preview). Both check claims['repository_id'] eq '348201813' and claims['repository_owner_id'] eq '11635254'. Plan adds claims['sub'] matches 'repo:*'; apply adds claims['sub'] eq 'repo:hackforla/incubator:ref:refs/heads/main', mirroring the AWS roles.
  • Grant subscription-scope roles. incubator-tf-apply: Contributor and Role Based Access Control Administrator. incubator-tf-plan: Reader and Key Vault Secrets User (so a plan can refresh Key Vault secrets, like IncubatorTfPlanSecretsRead on AWS).
  • Grant Microsoft Graph permissions with azuread_app_role_assignment. incubator-tf-apply: Application.ReadWrite.OwnedBy, so incubator can create and manage the shared app registration. incubator-tf-plan: Application.Read.All.
  • Output both identities' client IDs.
  • Put a header comment on the new file explaining that this repo's own Azure identities are hand-made and deliberately absent, as aws-gha-oidc-providers.tf does for AWS, pointing at terraform/azure-ci-bootstrap.md.
  • Run terraform init -backend=false and terraform validate with the pinned Terraform version before opening the PR.
  • After the PR merges, confirm the apply run logged in to Azure and created everything, and that the next unrelated PR's plan still passes.
  • After the PR merges, add the repository variables AZURE_TENANT_ID, AZURE_SUBSCRIPTION_ID, AZURE_CLIENT_ID_PLAN and AZURE_CLIENT_ID_APPLY to hackforla/incubator from the outputs. This repo has no GitHub provider, so they're set by hand.

Resources/Instructions

Activity

  1. added this to the 02 security milestone on Dec 1, 2026
  2. self-assigned this
    on Dec 1, 2026
  3. moved this from New Issue Review to In progress (actively working) in CoP: DevOps: Project Boardon Dec 1, 2026
  4. ale210 commented on Dec 1, 2026

    @ale210
    MemberAuthor

    Two action items were delivered differently in #240:

    • No azure/login step. Terraform runs inside the dflook container action, which can't see the runner's az login. The providers log in themselves with OIDC instead, through ARM_USE_OIDC/ARM_CLIENT_ID/ARM_TENANT_ID/ARM_SUBSCRIPTION_ID on the dflook steps; GitHub passes its OIDC token-request variables into the container. Proven by Add Azure providers and create incubator's Azure CI identities #240's plan and the post-merge apply.
    • No default_tags on azapi. Its only resources here are federated identity credentials, which can't be tagged. Taggable resources use azurerm with local.azure_tags.
  5. moved this from In progress (actively working) to Done in CoP: DevOps: Project Boardon Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions