Skip to content

Add Azure providers and create incubator's Azure CI identities - #240

Merged
ale210 merged 2 commits into
mainfrom
238-azure-incubator-ci-identities
Dec 1, 2026
Merged

ale210 merged 2 commits into
mainfrom
238-azure-incubator-ci-identities

Conversation

@ale210

@ale210 ale210 commented Dec 1, 2026

Copy link
Copy Markdown
Member

Part of #238.

Adds Azure to this repo's Terraform and creates the Azure identities hackforla/incubator's Terraform CI will log in with, mirroring incubator-tf-plan / incubator-tf-apply on AWS.

  • backend.tf: azurerm, azuread and azapi providers. azurerm skips resource provider registration, which the Reader-only plan identity can't do.
  • azure-ci-identities.tf (new), gated on iam_only like cloudtrail.tf: resource group incubator-ci, identities incubator-tf-plan / incubator-tf-apply, flexible federated credentials via azapi (apply trusts main only), subscription roles, and Graph app-role grants. Outputs both client IDs.
  • Workflows: the Azure providers log in with OIDC via ARM_* variables on the dflook steps, as this repo's hand-made identities (terraform/azure-ci-bootstrap.md). No azure/login: it signs in the runner's CLI, which the dflook container can't see.
  • README: covers Azure.

Expected plan: 11 to add, 0 to change, 0 to destroy (all Azure; no AWS changes). A local read-only plan against production state matched. This PR's CI plan is also the first proof that the plan identity's OIDC login works from inside the dflook container.

Known gap, not addressed here: with azurerm/azuread in place, a local run needs an Azure login even with iam_only = true.

After merge: confirm the apply logged in and created the 11 resources, then set incubator's AZURE_* repository variables from the outputs.

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Terraform plan in terraform
With backend config files: terraform/prod.backend.tfvars
With variables: iam_only = false

Plan: 11 to add, 0 to change, 0 to destroy. Changes to Outputs.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+   create

Terraform will perform the following actions:

  # azapi_resource.incubator_ci_federated_credential["apply"] will be created
+   resource "azapi_resource" "incubator_ci_federated_credential" {
+       body                      = {
+           properties = {
+               audiences                = [
+                   "api://AzureADTokenExchange",
                ]
+               claimsMatchingExpression = {
+                   languageVersion = 1
+                   value           = "claims['sub'] eq 'repo:hackforla/incubator:ref:refs/heads/main' and claims['repository_id'] eq '348201813' and claims['repository_owner_id'] eq '11635254'"
                }
+               issuer                   = "https://token.actions.githubusercontent.com"
            }
        }
+       id                        = (known after apply)
+       ignore_body_changes       = (write-only attribute)
+       ignore_casing             = false
+       ignore_missing_property   = true
+       ignore_null_property      = false
+       name                      = "github-incubator"
+       output                    = (known after apply)
+       parent_id                 = (known after apply)
+       schema_validation_enabled = false
+       sensitive_body            = (write-only attribute)
+       type                      = "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials@2025-05-31-preview"
    }

  # azapi_resource.incubator_ci_federated_credential["plan"] will be created
+   resource "azapi_resource" "incubator_ci_federated_credential" {
+       body                      = {
+           properties = {
+               audiences                = [
+                   "api://AzureADTokenExchange",
                ]
+               claimsMatchingExpression = {
+                   languageVersion = 1
+                   value           = "claims['sub'] matches 'repo:*' and claims['repository_id'] eq '348201813' and claims['repository_owner_id'] eq '11635254'"
                }
+               issuer                   = "https://token.actions.githubusercontent.com"
            }
        }
+       id                        = (known after apply)
+       ignore_body_changes       = (write-only attribute)
+       ignore_casing             = false
+       ignore_missing_property   = true
+       ignore_null_property      = false
+       name                      = "github-incubator"
+       output                    = (known after apply)
+       parent_id                 = (known after apply)
+       schema_validation_enabled = false
+       sensitive_body            = (write-only attribute)
+       type                      = "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials@2025-05-31-preview"
    }

  # azuread_app_role_assignment.incubator_ci["apply-app-readwrite-ownedby"] will be created
+   resource "azuread_app_role_assignment" "incubator_ci" {
+       app_role_id            = "************************************"
+       id                     = (known after apply)
+       principal_display_name = (known after apply)
+       principal_object_id    = (known after apply)
+       principal_type         = (known after apply)
+       resource_display_name  = (known after apply)
+       resource_object_id     = "************************************"
    }

  # azuread_app_role_assignment.incubator_ci["plan-app-read-all"] will be created
+   resource "azuread_app_role_assignment" "incubator_ci" {
+       app_role_id            = "************************************"
+       id                     = (known after apply)
+       principal_display_name = (known after apply)
+       principal_object_id    = (known after apply)
+       principal_type         = (known after apply)
+       resource_display_name  = (known after apply)
+       resource_object_id     = "************************************"
    }

  # azurerm_resource_group.incubator_ci[0] will be created
+   resource "azurerm_resource_group" "incubator_ci" {
+       id       = (known after apply)
+       location = "westus2"
+       name     = "incubator-ci"
+       tags     = {
+           "managed-by" = "terraform-devops-security"
        }
    }

  # azurerm_role_assignment.incubator_ci["apply-contributor"] will be created
+   resource "azurerm_role_assignment" "incubator_ci" {
+       condition_version                = (known after apply)
+       id                               = (known after apply)
+       name                             = (known after apply)
+       principal_id                     = (known after apply)
+       principal_type                   = "ServicePrincipal"
+       role_definition_id               = (known after apply)
+       role_definition_name             = "Contributor"
+       scope                            = "/subscriptions/12253474-af37-486c-bf98-182c9b3bdeb2"
+       skip_service_principal_aad_check = (known after apply)
    }

  # azurerm_role_assignment.incubator_ci["apply-rbac-admin"] will be created
+   resource "azurerm_role_assignment" "incubator_ci" {
+       condition_version                = (known after apply)
+       id                               = (known after apply)
+       name                             = (known after apply)
+       principal_id                     = (known after apply)
+       principal_type                   = "ServicePrincipal"
+       role_definition_id               = (known after apply)
+       role_definition_name             = "Role Based Access Control Administrator"
+       scope                            = "/subscriptions/12253474-af37-486c-bf98-182c9b3bdeb2"
+       skip_service_principal_aad_check = (known after apply)
    }

  # azurerm_role_assignment.incubator_ci["plan-kv-secrets"] will be created
+   resource "azurerm_role_assignment" "incubator_ci" {
+       condition_version                = (known after apply)
+       id                               = (known after apply)
+       name                             = (known after apply)
+       principal_id                     = (known after apply)
+       principal_type                   = "ServicePrincipal"
+       role_definition_id               = (known after apply)
+       role_definition_name             = "Key Vault Secrets User"
+       scope                            = "/subscriptions/12253474-af37-486c-bf98-182c9b3bdeb2"
+       skip_service_principal_aad_check = (known after apply)
    }

  # azurerm_role_assignment.incubator_ci["plan-reader"] will be created
+   resource "azurerm_role_assignment" "incubator_ci" {
+       condition_version                = (known after apply)
+       id                               = (known after apply)
+       name                             = (known after apply)
+       principal_id                     = (known after apply)
+       principal_type                   = "ServicePrincipal"
+       role_definition_id               = (known after apply)
+       role_definition_name             = "Reader"
+       scope                            = "/subscriptions/12253474-af37-486c-bf98-182c9b3bdeb2"
+       skip_service_principal_aad_check = (known after apply)
    }

  # azurerm_user_assigned_identity.incubator_ci["apply"] will be created
+   resource "azurerm_user_assigned_identity" "incubator_ci" {
+       client_id           = (known after apply)
+       id                  = (known after apply)
+       location            = "westus2"
+       name                = "incubator-tf-apply"
+       principal_id        = (known after apply)
+       resource_group_name = "incubator-ci"
+       tags                = {
+           "managed-by" = "terraform-devops-security"
        }
+       tenant_id           = (known after apply)
    }

  # azurerm_user_assigned_identity.incubator_ci["plan"] will be created
+   resource "azurerm_user_assigned_identity" "incubator_ci" {
+       client_id           = (known after apply)
+       id                  = (known after apply)
+       location            = "westus2"
+       name                = "incubator-tf-plan"
+       principal_id        = (known after apply)
+       resource_group_name = "incubator-ci"
+       tags                = {
+           "managed-by" = "terraform-devops-security"
        }
+       tenant_id           = (known after apply)
    }

Plan: 11 to add, 0 to change, 0 to destroy.

Changes to Outputs:
+   incubator_azure_ci_client_ids = {
+       apply = (known after apply)
+       plan  = (known after apply)
    }

✅ Plan applied in Apply Terraform changes on merge #65

Outputs
incubator_azure_ci_client_ids = {
    apply = "3ed75320-4929-4cc2-bd82-7b25f50c2577"
    plan  = "47e2bdcb-3c85-4d59-be12-869552bba440"
}

@ale210
ale210 merged commit 870d6c8 into main Dec 1, 2026
1 check passed
@ale210
ale210 deleted the 238-azure-incubator-ci-identities branch December 1, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant