diff --git a/infra/github-runner/.terraform.lock.hcl b/infra/github-runner/.terraform.lock.hcl new file mode 100644 index 00000000..a5748633 --- /dev/null +++ b/infra/github-runner/.terraform.lock.hcl @@ -0,0 +1,48 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/azure/azapi" { + version = "1.12.1" + constraints = "<= 1.12.1" + hashes = [ + "h1:4uNzgEfL4VJ48QYAKM4A/E+HWyx7roO58xmR3R2WNh0=", + "h1:EaQL7pQCRm5iL2zy/dG7rOe2OZ0ZypuyVnpQAiAwJmM=", + "h1:Gv1HwQMV7+3ctMPr1nKmOhEGu+UWb6FlQmrgaHxknJ4=", + "h1:H9n5gOhlN5GT5WIhasUbxIONS/6BfRP9ES1oQop2wxk=", + "zh:1cf52e685ceb04e73e13fbf3f3036bff23a3274a4ceda8693c0612076a588166", + "zh:321b59c2a67c6cb4e5cf0dbe2cc978f5389d781e8b391f9b75bf4d830abd2ffe", + "zh:49046bd8020c3b44c6b5dc67041f181e4fff45e3bc1a9ff0646dd20c21c8ce47", + "zh:5784d0c326ec4825571577bc39b253019bd3b1030c19d67ca3436df2d7ba01c8", + "zh:5ad7e18d26f170c01888d8e65dab7aa475089aac7bf0106526fd57cdd56533bc", + "zh:6695854f4f655673bea85e37444bf0c070b440dba4bc269aa144d0f6b7c1cc5f", + "zh:7f372c897da6b9ad90869a8eb85b37dad4dff2d5d311b3eca1a2e6373e2271ed", + "zh:8afa1a2be1dada4e8be4ab72d9d56f36af1e486c9353d04aabf6e79db7310125", + "zh:90809364619238c45185bff25c7d9c4fde34253561d8183ebbe797456c44bc9c", + "zh:9338d44650c9e68e10a6bc2d69f7beacd5059e6ac681d2e388e80a1652d9c183", + "zh:c94ee6fb1df2c1d35f338107b5e73cdba86c4ecf9dcde95e2ca0132cbbd4bd7c", + "zh:de231d363b1a664c6b5d3af8d3b9cf542d04d4506fb9458ba6c8ebf94e0e32ae", + ] +} + +provider "registry.terraform.io/hashicorp/azurerm" { + version = "3.97.1" + constraints = ">= 3.50.0, <= 3.97.1, <= 3.98.0" + hashes = [ + "h1:LtwGbd4HEb5QCXmdxSvTjPSh8/Gp8eAQMYfiAKaubV4=", + "h1:klBuN2uVZF7AVMhskbbgF8pygyhPBxsjedB1GUV79PA=", + "h1:m5wyoRGjbVfJU2YaGZrN1lfGgjpyuwi7Ykw1uHdwlAg=", + "h1:vwYchGsh1TY+/GjUv6CUS6It2opnMYYYVt4GBvCmesY=", + "zh:15171efcc3aa3a37748c502c493cb16ecff603b81ada4499a843574976bac524", + "zh:2ca6c13a4a96f67763ecced0015c7b101ee02d54ea54b28a8df4ae06468071b1", + "zh:2e3c77dbfd8f760132ecef2d6117e939cbea26b96aba5e4d926e7f7f0f7afe72", + "zh:4bc346eece1622be93c73801d8256502b11fd7c2e7f7cea12d048bb9fc9fe900", + "zh:4f1042942ed8d0433680a367527289459d43b0894a51eaba83ac414e80d5187f", + "zh:63e674c31482ae3579ea84daf5b1ba066ce40cb23475f54e17b6b131320a1bec", + "zh:8327148766dcb7a174673729a832c8095d7e137d0e6c7e2a9a01da48b8b73fbe", + "zh:851b3ae417059a80c7813e7f0063298a590a42f056004f2c2558ea14061c207e", + "zh:ac081b48907139c121a422ae9b1f40fc72c6aaaeb05cbdbf848102a6a5f426f4", + "zh:dc1d663df2d95e4ba91070ceb20d3560b6ea5c465d39c57a5979319302643e41", + "zh:ed26457367cbbb94237e935d297cb31b5687f9abf697377da0ee46974480db9b", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} diff --git a/infra/github-runner/container_app_job_runner.tf b/infra/github-runner/container_app_job_runner.tf new file mode 100644 index 00000000..315c30e0 --- /dev/null +++ b/infra/github-runner/container_app_job_runner.tf @@ -0,0 +1,25 @@ +module "container_app_job" { + source = "github.com/pagopa/terraform-azurerm-v3//container_app_job_gh_runner?ref=v7.76.0" + + location = local.location + prefix = local.prefix + env_short = local.env_short + + key_vault = { + resource_group_name = data.azurerm_key_vault.key_vault_common.resource_group_name + name = data.azurerm_key_vault.key_vault_common.name + secret_name = "github-runner-pat" + } + + environment = { + name = data.azurerm_container_app_environment.container_app_environment_runner.name + resource_group_name = data.azurerm_container_app_environment.container_app_environment_runner.resource_group_name + } + + job = { + name = "service-messages" + repo = "io-functions-service-messages" + } + + tags = local.tags +} diff --git a/infra/github-runner/data.tf b/infra/github-runner/data.tf new file mode 100644 index 00000000..22ce5dc8 --- /dev/null +++ b/infra/github-runner/data.tf @@ -0,0 +1,9 @@ +data "azurerm_key_vault" "key_vault_common" { + name = local.key_vault_common.name + resource_group_name = local.key_vault_common.resource_group_name +} + +data "azurerm_container_app_environment" "container_app_environment_runner" { + name = local.container_app_environment.name + resource_group_name = local.container_app_environment.resource_group_name +} diff --git a/infra/github-runner/locals.tf b/infra/github-runner/locals.tf new file mode 100644 index 00000000..aa5247f9 --- /dev/null +++ b/infra/github-runner/locals.tf @@ -0,0 +1,25 @@ +locals { + location = "westeurope" + prefix = "io" + env_short = "p" + project = "${local.prefix}-${local.env_short}" + + key_vault_common = { + name = "${local.project}-kv-common" + resource_group_name = "${local.project}-rg-common" + } + + container_app_environment = { + name = "${local.project}-github-runner-cae" + resource_group_name = "${local.project}-github-runner-rg" + } + + tags = { + CostCenter = "TS310 - PAGAMENTI & SERVIZI" + CreatedBy = "Terraform" + Environment = "Prod" + Owner = "IO" + ManagementTeam = "IO Comunicazione" + Source = "https://github.com/pagopa/io-functions-service-messages/tree/main/infra/github-runner" + } +} diff --git a/infra/github-runner/main.tf b/infra/github-runner/main.tf new file mode 100644 index 00000000..7265c96a --- /dev/null +++ b/infra/github-runner/main.tf @@ -0,0 +1,19 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "<= 3.98.0" + } + } + + backend "azurerm" { + resource_group_name = "terraform-state-rg" + storage_account_name = "tfappprodio" + container_name = "terraform-state" + key = "io-functions-service-messages.github-runner.tfstate" + } +} + +provider "azurerm" { + features {} +}