Skip to content

Commit

Permalink
feat: add eCommerce user stats service CR and deploy pipelines (#365)
Browse files Browse the repository at this point in the history
* feat: add eCommerce user stats service CR and deploy pipelines

* fix pre-commit
  • Loading branch information
pietro-tota authored Oct 2, 2024
1 parent 8e300f1 commit ac7b3e2
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 24 deletions.
130 changes: 130 additions & 0 deletions azure-devops/ecommerce/06_pagopa-ecommerce-user-stats-service.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
variable "pagopa-ecommerce-user-stats-service" {
default = {
repository = {
organization = "pagopa"
name = "pagopa-ecommerce-user-stats-service"
branch_name = "refs/heads/main"
pipelines_path = ".devops"
yml_prefix_name = null
}
pipeline = {
enable_code_review = true
enable_deploy = true
sonarcloud = {
# TODO azure devops terraform provider does not support SonarCloud service endpoint
service_connection = "SONARCLOUD-SERVICE-CONN"
org = "pagopa"
project_key = "pagopa_pagopa-ecommerce-user-stats-service"
project_name = "pagopa-ecommerce-user-stats-service"
}
}
}
}

locals {
# global vars
pagopa-ecommerce-user-stats-service-variables = {
cache_version_id = "v1"
default_branch = var.pagopa-ecommerce-user-stats-service.repository.branch_name
}
# global secrets
pagopa-ecommerce-user-stats-service-variables_secret = {

}
# code_review vars
pagopa-ecommerce-user-stats-service-variables_code_review = {
danger_github_api_token = "skip"
sonarcloud_service_conn = var.pagopa-ecommerce-user-stats-service.pipeline.sonarcloud.service_connection
sonarcloud_org = var.pagopa-ecommerce-user-stats-service.pipeline.sonarcloud.org
sonarcloud_project_key = var.pagopa-ecommerce-user-stats-service.pipeline.sonarcloud.project_key
sonarcloud_project_name = var.pagopa-ecommerce-user-stats-service.pipeline.sonarcloud.project_name
}
# code_review secrets
pagopa-ecommerce-user-stats-service-variables_secret_code_review = {

}
# deploy vars
pagopa-ecommerce-user-stats-service-variables_deploy = {
github_connection = data.azuredevops_serviceendpoint_github.github_rw.service_endpoint_name

# acr section
k8s_image_repository_name = replace(var.pagopa-ecommerce-user-stats-service.repository.name, "-", "")
dev_container_registry_service_conn = data.azuredevops_serviceendpoint_azurecr.dev_weu_workload_identity.id
dev_container_registry_name = data.azuredevops_serviceendpoint_azurecr.dev_weu_workload_identity.service_endpoint_name
uat_container_registry_service_conn = data.azuredevops_serviceendpoint_azurecr.uat_weu_workload_identity.id
uat_container_registry_name = data.azuredevops_serviceendpoint_azurecr.uat_weu_workload_identity.service_endpoint_name
#prod_container_registry_service_conn = data.azuredevops_serviceendpoint_azurecr.prod_weu_workload_identity.id
#prod_container_registry_name = data.azuredevops_serviceendpoint_azurecr.prod_weu_workload_identity.service_endpoint_name

# aks section
dev_kubernetes_service_conn = azuredevops_serviceendpoint_kubernetes.aks_dev.id
uat_kubernetes_service_conn = azuredevops_serviceendpoint_kubernetes.aks_uat.id
#prod_kubernetes_service_conn = azuredevops_serviceendpoint_kubernetes.aks_prod.id

dev_container_namespace = "pagopadcommonacr.azurecr.io"
uat_container_namespace = "pagopaucommonacr.azurecr.io"
#prod_container_namespace = "pagopapcommonacr.azurecr.io"

}
# deploy secrets
pagopa-ecommerce-user-stats-service-variables_secret_deploy = {
git_mail = module.secrets.values["azure-devops-github-EMAIL"].value
git_username = module.secrets.values["azure-devops-github-USERNAME"].value
tenant_id = data.azurerm_client_config.current.tenant_id
}
}

module "pagopa-ecommerce-user-stats-service_code_review" {
source = "git::https://github.com/pagopa/azuredevops-tf-modules.git//azuredevops_build_definition_code_review?ref=v5.1.1"
count = var.pagopa-ecommerce-user-stats-service.pipeline.enable_code_review == true ? 1 : 0

project_id = data.azuredevops_project.project.id
repository = var.pagopa-ecommerce-user-stats-service.repository
github_service_connection_id = data.azuredevops_serviceendpoint_github.github_pr.service_endpoint_id
path = "${local.domain}\\pagopa-ecommerce-user-stats-service"

variables = merge(
local.pagopa-ecommerce-user-stats-service-variables,
local.pagopa-ecommerce-user-stats-service-variables_code_review,
)

variables_secret = merge(
local.pagopa-ecommerce-user-stats-service-variables_secret,
local.pagopa-ecommerce-user-stats-service-variables_secret_code_review,
)

service_connection_ids_authorization = [
local.azuredevops_serviceendpoint_sonarcloud_id,
data.azuredevops_serviceendpoint_github.github_ro.service_endpoint_id
]
}

module "pagopa-ecommerce-user-stats-service_deploy" {
source = "git::https://github.com/pagopa/azuredevops-tf-modules.git//azuredevops_build_definition_deploy?ref=v4.2.1"
count = var.pagopa-ecommerce-user-stats-service.pipeline.enable_deploy == true ? 1 : 0

project_id = data.azuredevops_project.project.id
repository = var.pagopa-ecommerce-user-stats-service.repository
github_service_connection_id = data.azuredevops_serviceendpoint_github.github_rw.service_endpoint_id
path = "${local.domain}\\pagopa-ecommerce-user-stats-service"

variables = merge(
local.pagopa-ecommerce-user-stats-service-variables,
local.pagopa-ecommerce-user-stats-service-variables_deploy,
)

variables_secret = merge(
local.pagopa-ecommerce-user-stats-service-variables_secret,
local.pagopa-ecommerce-user-stats-service-variables_secret_deploy,
)

service_connection_ids_authorization = [
data.azuredevops_serviceendpoint_github.github_ro.id,
data.azuredevops_serviceendpoint_azurecr.dev_weu_workload_identity.id,
data.azuredevops_serviceendpoint_azurecr.uat_weu_workload_identity.id,
#data.azuredevops_serviceendpoint_azurecr.prod_weu_workload_identity.id,
data.azuredevops_serviceendpoint_azurerm.dev.id,
data.azuredevops_serviceendpoint_azurerm.uat.id,
#data.azuredevops_serviceendpoint_azurerm.prod.id,
]
}
3 changes: 3 additions & 0 deletions azure-devops/ecommerce/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
| <a name="module_pagopa-ecommerce-transactions-scheduler-service_deploy"></a> [pagopa-ecommerce-transactions-scheduler-service\_deploy](#module\_pagopa-ecommerce-transactions-scheduler-service\_deploy) | git::https://github.com/pagopa/azuredevops-tf-modules.git//azuredevops_build_definition_deploy | v4.2.1 |
| <a name="module_pagopa-ecommerce-transactions-service_code_review"></a> [pagopa-ecommerce-transactions-service\_code\_review](#module\_pagopa-ecommerce-transactions-service\_code\_review) | git::https://github.com/pagopa/azuredevops-tf-modules.git//azuredevops_build_definition_code_review | v5.1.1 |
| <a name="module_pagopa-ecommerce-transactions-service_deploy"></a> [pagopa-ecommerce-transactions-service\_deploy](#module\_pagopa-ecommerce-transactions-service\_deploy) | git::https://github.com/pagopa/azuredevops-tf-modules.git//azuredevops_build_definition_deploy | v4.2.1 |
| <a name="module_pagopa-ecommerce-user-stats-service_code_review"></a> [pagopa-ecommerce-user-stats-service\_code\_review](#module\_pagopa-ecommerce-user-stats-service\_code\_review) | git::https://github.com/pagopa/azuredevops-tf-modules.git//azuredevops_build_definition_code_review | v5.1.1 |
| <a name="module_pagopa-ecommerce-user-stats-service_deploy"></a> [pagopa-ecommerce-user-stats-service\_deploy](#module\_pagopa-ecommerce-user-stats-service\_deploy) | git::https://github.com/pagopa/azuredevops-tf-modules.git//azuredevops_build_definition_deploy | v4.2.1 |
| <a name="module_secrets"></a> [secrets](#module\_secrets) | git::https://github.com/pagopa/terraform-azurerm-v3.git//key_vault_secrets_query | v7.39.0 |

## Resources
Expand Down Expand Up @@ -86,6 +88,7 @@
| <a name="input_pagopa-ecommerce-tests"></a> [pagopa-ecommerce-tests](#input\_pagopa-ecommerce-tests) | n/a | `map` | <pre>{<br> "pipeline": {<br> "enable_soak": true,<br> "name": "soak-test-pipeline"<br> },<br> "repository": {<br> "branch_name": "refs/heads/main",<br> "name": "pagopa-ecommerce-tests",<br> "organization": "pagopa",<br> "pipeline_yml_filename": "soaktest.yaml",<br> "pipelines_path": ".devops",<br> "yml_prefix_name": null<br> }<br>}</pre> | no |
| <a name="input_pagopa-ecommerce-transactions-scheduler-service"></a> [pagopa-ecommerce-transactions-scheduler-service](#input\_pagopa-ecommerce-transactions-scheduler-service) | n/a | `map` | <pre>{<br> "pipeline": {<br> "enable_code_review": true,<br> "enable_deploy": true,<br> "sonarcloud": {<br> "org": "pagopa",<br> "project_key": "pagopa_pagopa-ecommerce-transactions-scheduler-service",<br> "project_name": "pagopa-ecommerce-transactions-scheduler-service",<br> "service_connection": "SONARCLOUD-SERVICE-CONN"<br> }<br> },<br> "repository": {<br> "branch_name": "refs/heads/main",<br> "name": "pagopa-ecommerce-transactions-scheduler-service",<br> "organization": "pagopa",<br> "pipelines_path": ".devops",<br> "yml_prefix_name": null<br> }<br>}</pre> | no |
| <a name="input_pagopa-ecommerce-transactions-service"></a> [pagopa-ecommerce-transactions-service](#input\_pagopa-ecommerce-transactions-service) | n/a | `map` | <pre>{<br> "pipeline": {<br> "enable_code_review": true,<br> "enable_deploy": true,<br> "sonarcloud": {<br> "org": "pagopa",<br> "project_key": "pagopa_pagopa-ecommerce-transactions-service",<br> "project_name": "pagopa-ecommerce-transactions-service",<br> "service_connection": "SONARCLOUD-SERVICE-CONN"<br> }<br> },<br> "repository": {<br> "branch_name": "refs/heads/main",<br> "name": "pagopa-ecommerce-transactions-service",<br> "organization": "pagopa",<br> "pipelines_path": ".devops",<br> "yml_prefix_name": null<br> }<br>}</pre> | no |
| <a name="input_pagopa-ecommerce-user-stats-service"></a> [pagopa-ecommerce-user-stats-service](#input\_pagopa-ecommerce-user-stats-service) | n/a | `map` | <pre>{<br> "pipeline": {<br> "enable_code_review": true,<br> "enable_deploy": true,<br> "sonarcloud": {<br> "org": "pagopa",<br> "project_key": "pagopa_pagopa-ecommerce-user-stats-service",<br> "project_name": "pagopa-ecommerce-user-stats-service",<br> "service_connection": "SONARCLOUD-SERVICE-CONN"<br> }<br> },<br> "repository": {<br> "branch_name": "refs/heads/main",<br> "name": "pagopa-ecommerce-user-stats-service",<br> "organization": "pagopa",<br> "pipelines_path": ".devops",<br> "yml_prefix_name": null<br> }<br>}</pre> | no |
| <a name="input_pagopa-notifications-service"></a> [pagopa-notifications-service](#input\_pagopa-notifications-service) | n/a | `map` | <pre>{<br> "pipeline": {<br> "enable_code_review": true,<br> "enable_deploy": true,<br> "sonarcloud": {<br> "org": "pagopa",<br> "project_key": "pagopa_pagopa-notifications-service",<br> "project_name": "pagopa-notifications-service",<br> "service_connection": "SONARCLOUD-SERVICE-CONN"<br> }<br> },<br> "repository": {<br> "branch_name": "refs/heads/main",<br> "name": "pagopa-notifications-service",<br> "organization": "pagopa",<br> "pipelines_path": ".devops",<br> "yml_prefix_name": null<br> }<br>}</pre> | no |
| <a name="input_pipeline_environments"></a> [pipeline\_environments](#input\_pipeline\_environments) | List of environments pipeline to create | `list(any)` | n/a | yes |
| <a name="input_prod_subscription_name"></a> [prod\_subscription\_name](#input\_prod\_subscription\_name) | PROD Subscription name | `string` | n/a | yes |
Expand Down
Loading

0 comments on commit ac7b3e2

Please sign in to comment.