Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application_id & skip_provider_registration deprecated #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion terraform-example-deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ terraform {
}

provider "azurerm" {
skip_provider_registration = true
resource_provider_registrations = "none"
features {}
}

Expand Down
18 changes: 9 additions & 9 deletions terraform-oidc-config/app_registration.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ resource "azuread_application" "github_oidc" {
}

resource "azuread_service_principal" "github_oidc" {
for_each = local.app_registration_environments
application_id = azuread_application.github_oidc[each.value].application_id
for_each = local.app_registration_environments
client_id = azuread_application.github_oidc[each.value].client_id
}

resource "azuread_application_federated_identity_credential" "github_oidc" {
for_each = local.app_registration_environments
application_object_id = azuread_application.github_oidc[each.value].object_id
display_name = "${var.azure_devops_organisation_target}-${var.azure_devops_project_target}-${each.value}"
description = "Deployments for ${var.azure_devops_organisation_target}/${var.azure_devops_project_target} for environment ${each.value}"
audiences = [local.default_audience_name]
issuer = azuredevops_serviceendpoint_azurerm.oidc[each.key].workload_identity_federation_issuer
subject = azuredevops_serviceendpoint_azurerm.oidc[each.key].workload_identity_federation_subject
for_each = local.app_registration_environments
application_id = "/applications/${azuread_application.github_oidc[each.value].object_id}"
display_name = "${var.azure_devops_organisation_target}-${var.azure_devops_project_target}-${each.value}"
description = "Deployments for ${var.azure_devops_organisation_target}/${var.azure_devops_project_target} for environment ${each.value}"
audiences = [local.default_audience_name]
issuer = azuredevops_serviceendpoint_azurerm.oidc[each.key].workload_identity_federation_issuer
subject = azuredevops_serviceendpoint_azurerm.oidc[each.key].workload_identity_federation_subject
}
2 changes: 1 addition & 1 deletion terraform-oidc-config/azure_devops_service_connections.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resource "azuredevops_serviceendpoint_azurerm" "oidc" {
description = "Managed by Terraform"
service_endpoint_authentication_scheme = "WorkloadIdentityFederation"
credentials {
serviceprincipalid = local.security_option.oidc_with_app_registration ? azuread_application.github_oidc[each.value].application_id : azurerm_user_assigned_identity.example[each.value].client_id
serviceprincipalid = local.security_option.oidc_with_app_registration ? azuread_application.github_oidc[each.value].client_id : azurerm_user_assigned_identity.example[each.value].client_id
}
azurerm_spn_tenantid = data.azurerm_client_config.current.tenant_id
azurerm_subscription_id = data.azurerm_client_config.current.subscription_id
Expand Down
2 changes: 1 addition & 1 deletion terraform-oidc-config/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ output "tenant_id" {
}

output "service_principal_client_ids" {
value = local.security_option.oidc_with_app_registration ? { for env in var.environments : env => azuread_application.github_oidc[env].application_id } : { for env in var.environments : env => azurerm_user_assigned_identity.example[env].client_id }
value = local.security_option.oidc_with_app_registration ? { for env in var.environments : env => azuread_application.github_oidc[env].client_id } : { for env in var.environments : env => azurerm_user_assigned_identity.example[env].client_id }
}