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.
- Loading branch information
1 parent
db91137
commit 9b9d935
Showing
2 changed files
with
90 additions
and
58 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,90 @@ | ||
module "github_runner_app" { | ||
source = "git::https://github.com/pagopa/github-actions-tf-modules.git//app-github-runner-creator?ref=main" | ||
|
||
app_name = local.app_name | ||
|
||
subscription_id = data.azurerm_subscription.current.id | ||
|
||
github_org = local.github.org | ||
github_repository = local.github.repository | ||
github_environment_name = var.env | ||
|
||
container_app_github_runner_env_rg = local.container_app_environment.resource_group | ||
} | ||
|
||
resource "null_resource" "github_runner_app_permissions_to_namespace" { | ||
triggers = { | ||
aks_id = data.azurerm_kubernetes_cluster.aks.id | ||
service_principal_id = module.github_runner_app.client_id | ||
namespace = local.domain | ||
version = "v2" | ||
} | ||
|
||
provisioner "local-exec" { | ||
command = <<EOT | ||
az role assignment create --role "Azure Kubernetes Service RBAC Admin" \ | ||
--assignee ${self.triggers.service_principal_id} \ | ||
--scope ${self.triggers.aks_id}/namespaces/${self.triggers.namespace} | ||
az role assignment list --role "Azure Kubernetes Service RBAC Admin" \ | ||
--scope ${self.triggers.aks_id}/namespaces/${self.triggers.namespace} | ||
EOT | ||
} | ||
|
||
provisioner "local-exec" { | ||
when = destroy | ||
command = <<EOT | ||
az role assignment delete --role "Azure Kubernetes Service RBAC Admin" \ | ||
--assignee ${self.triggers.service_principal_id} \ | ||
--scope ${self.triggers.aks_id}/namespaces/${self.triggers.namespace} | ||
EOT | ||
} | ||
} | ||
|
||
resource "azurerm_role_assignment" "environment_terraform_resource_group_dashboards" { | ||
scope = data.azurerm_resource_group.dashboards.id | ||
role_definition_name = "Contributor" | ||
principal_id = module.github_runner_app.object_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "environment_function" { | ||
scope = data.azurerm_resource_group.gpd_rg.id | ||
role_definition_name = "Contributor" | ||
principal_id = module.github_runner_app.object_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "environment_key_vault" { | ||
scope = data.azurerm_key_vault.key_vault.id | ||
role_definition_name = "Reader" | ||
principal_id = module.github_runner_app.object_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "environment_key_vault_domain" { | ||
scope = data.azurerm_key_vault.domain_key_vault.id | ||
role_definition_name = "Reader" | ||
principal_id = module.github_runner_app.object_id | ||
} | ||
|
||
resource "azurerm_key_vault_access_policy" "ad_kv_group_policy" { | ||
key_vault_id = data.azurerm_key_vault.key_vault.id | ||
|
||
tenant_id = data.azurerm_client_config.current.tenant_id | ||
object_id = module.github_runner_app.object_id | ||
|
||
key_permissions = [] | ||
secret_permissions = ["Get", "List"] | ||
storage_permissions = [] | ||
certificate_permissions = [] | ||
} | ||
|
||
resource "azurerm_key_vault_access_policy" "ad_domain_kv_group_policy" { | ||
key_vault_id = data.azurerm_key_vault.domain_key_vault.id | ||
|
||
tenant_id = data.azurerm_client_config.current.tenant_id | ||
object_id = module.github_runner_app.object_id | ||
|
||
key_permissions = [] | ||
secret_permissions = ["Get", "List"] | ||
storage_permissions = [] | ||
certificate_permissions = [] | ||
} |