generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PRDP-175] feat: migrating to federated identity
- Loading branch information
1 parent
4c49bb2
commit 0f8e3d7
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
resource "azuread_application" "main" { | ||
display_name = "${local.app_name}-main" | ||
} | ||
|
||
resource "azuread_service_principal" "main" { | ||
application_id = azuread_application.main.application_id | ||
} | ||
|
||
resource "azuread_application_federated_identity_credential" "main" { | ||
application_object_id = azuread_application.main.object_id | ||
display_name = "github-federated" | ||
description = "github-federated" | ||
audiences = ["api://AzureADTokenExchange"] | ||
issuer = "https://token.actions.githubusercontent.com" | ||
subject = "repo:${local.github.org}/${local.github.repository}:environment:${var.env}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
resource "azurerm_role_assignment" "main_terraform_subscription" { | ||
scope = data.azurerm_subscription.current.id | ||
role_definition_name = "Reader" | ||
principal_id = azuread_service_principal.main.object_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "main_terraform_storage_account_tfstate_app" { | ||
scope = data.azurerm_storage_account.tfstate_app.id | ||
role_definition_name = "Contributor" | ||
principal_id = azuread_service_principal.main.object_id | ||
} | ||
resource "azurerm_role_assignment" "main_terraform_storage_account_tfstate_app_github_aks" { | ||
scope = data.azurerm_storage_account.tfstate_app.id | ||
role_definition_name = "Contributor" | ||
principal_id = module.github_runner_app.object_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "main_terraform_resource_group_dashboards" { | ||
scope = data.azurerm_resource_group.dashboards.id | ||
role_definition_name = "Contributor" | ||
principal_id = azuread_service_principal.main.object_id | ||
} |