Skip to content

Commit

Permalink
feat: Identity pr (#2079)
Browse files Browse the repository at this point in the history
identity pr
  • Loading branch information
jacopocarlini authored Jun 7, 2024
1 parent c0b6fb6 commit 00215dd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/domains/selfcare-common/10_github_identity.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ locals {
}
]

federations_01_pr = [
for repo in local.repos_01 : {
repository = repo
subject = "pull_request"
}
]

# to avoid subscription Contributor -> https://github.com/microsoft/azure-container-apps/issues/35
environment_cd_roles = {
subscription = [
Expand Down Expand Up @@ -108,3 +115,43 @@ resource "null_resource" "github_runner_app_permissions_to_namespace_cd_01" {
module.identity_cd_01
]
}


# create a module for each 20 repos
module "identity_pr_01" {
source = "github.com/pagopa/terraform-azurerm-v3//github_federated_identity?ref=fix-github-federated-identity"
prefix = var.prefix
env_short = var.env_short
domain = "${var.domain}-01-pr"

identity_role = "cd"

github_federations = local.federations_01_pr

cd_rbac_roles = {
subscription_roles = local.environment_cd_roles.subscription
resource_groups = local.environment_cd_roles.resource_groups
}

tags = var.tags

depends_on = [
data.azurerm_resource_group.identity_rg
]
}


resource "azurerm_key_vault_access_policy" "gha_pr_iac_managed_identities" {
key_vault_id = module.key_vault.id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = module.identity_pr_01.identity_principal_id

secret_permissions = ["Get", "List", "Set", ]

certificate_permissions = ["SetIssuers", "DeleteIssuers", "Purge", "List", "Get"]
key_permissions = [
"Get", "List", "Update", "Create", "Import", "Delete", "Encrypt", "Decrypt", "GetRotationPolicy"
]

storage_permissions = []
}
2 changes: 2 additions & 0 deletions src/domains/selfcare-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| <a name="module_bopagopa_cosmosdb_mongo_account"></a> [bopagopa\_cosmosdb\_mongo\_account](#module\_bopagopa\_cosmosdb\_mongo\_account) | git::https://github.com/pagopa/terraform-azurerm-v3.git//cosmosdb_account | v6.7.0 |
| <a name="module_bopagopa_cosmosdb_mongodb_snet"></a> [bopagopa\_cosmosdb\_mongodb\_snet](#module\_bopagopa\_cosmosdb\_mongodb\_snet) | git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet | v6.7.0 |
| <a name="module_identity_cd_01"></a> [identity\_cd\_01](#module\_identity\_cd\_01) | github.com/pagopa/terraform-azurerm-v3//github_federated_identity | v7.45.0 |
| <a name="module_identity_pr_01"></a> [identity\_pr\_01](#module\_identity\_pr\_01) | github.com/pagopa/terraform-azurerm-v3//github_federated_identity | fix-github-federated-identity |
| <a name="module_key_vault"></a> [key\_vault](#module\_key\_vault) | git::https://github.com/pagopa/terraform-azurerm-v3.git//key_vault | v6.7.0 |
| <a name="module_mongdb_collection_brokeribans"></a> [mongdb\_collection\_brokeribans](#module\_mongdb\_collection\_brokeribans) | git::https://github.com/pagopa/terraform-azurerm-v3.git//cosmosdb_mongodb_collection | v6.7.0 |
| <a name="module_mongdb_collection_brokerinstitutions"></a> [mongdb\_collection\_brokerinstitutions](#module\_mongdb\_collection\_brokerinstitutions) | git::https://github.com/pagopa/terraform-azurerm-v3.git//cosmosdb_mongodb_collection | v6.7.0 |
Expand Down Expand Up @@ -46,6 +47,7 @@
| [azurerm_key_vault_access_policy.azdevops_iac_managed_identities](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
| [azurerm_key_vault_access_policy.azdevops_iac_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
| [azurerm_key_vault_access_policy.gha_iac_managed_identities](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
| [azurerm_key_vault_access_policy.gha_pr_iac_managed_identities](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
| [azurerm_key_vault_secret.ai_connection_string](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource |
| [azurerm_key_vault_secret.cosmodb_mongo_bopagopa_connection_string](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource |
| [azurerm_key_vault_secret.cosmodb_mongo_bopagopa_key](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource |
Expand Down

0 comments on commit 00215dd

Please sign in to comment.