Skip to content

Commit

Permalink
[EC-357] Move ACR resources to modules (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty93 authored Aug 1, 2024
1 parent ee32085 commit 239bc8d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
| <a name="module_azdoa_li_infra"></a> [azdoa\_li\_infra](#module\_azdoa\_li\_infra) | github.com/pagopa/terraform-azurerm-v3//azure_devops_agent | v8.27.0 |
| <a name="module_azdoa_loadtest_li"></a> [azdoa\_loadtest\_li](#module\_azdoa\_loadtest\_li) | github.com/pagopa/terraform-azurerm-v3//azure_devops_agent | v8.27.0 |
| <a name="module_azdoa_snet"></a> [azdoa\_snet](#module\_azdoa\_snet) | github.com/pagopa/terraform-azurerm-v3//subnet | v8.27.0 |
| <a name="module_container_registry"></a> [container\_registry](#module\_container\_registry) | github.com/pagopa/terraform-azurerm-v3//container_registry | v8.27.0 |
| <a name="module_dns_forwarder"></a> [dns\_forwarder](#module\_dns\_forwarder) | github.com/pagopa/terraform-azurerm-v3//dns_forwarder | v8.27.0 |
| <a name="module_dns_forwarder_snet"></a> [dns\_forwarder\_snet](#module\_dns\_forwarder\_snet) | github.com/pagopa/terraform-azurerm-v3//subnet | v8.27.0 |
| <a name="module_event_hub"></a> [event\_hub](#module\_event\_hub) | github.com/pagopa/terraform-azurerm-v3//eventhub | v8.27.0 |
Expand Down Expand Up @@ -150,7 +149,6 @@
| [azurerm_public_ip.public_ip_apim](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) | resource |
| [azurerm_resource_group.assets_cdn_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_resource_group.azdo_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_resource_group.container_registry_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_resource_group.data](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_resource_group.default_roleassignment_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_resource_group.event_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
resource "azurerm_resource_group" "container_registry_rg" {
name = format("%s-container-registry-rg", local.project)
location = var.location

tags = var.tags
}

module "container_registry" {
source = "github.com/pagopa/terraform-azurerm-v3//container_registry?ref=v8.27.0"
name = replace(format("%s-common-acr", local.project), "-", "")
source = "github.com/pagopa/terraform-azurerm-v3//container_registry?ref=v8.34.0"
name = local.nonstandard[var.location_short].acr
sku = "Premium"
resource_group_name = azurerm_resource_group.container_registry_rg.name
resource_group_name = azurerm_resource_group.container_registry.name
admin_enabled = false
anonymous_pull_enabled = false
zone_redundancy_enabled = true
Expand Down
8 changes: 8 additions & 0 deletions src/core/_modules/container_registry/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
locals {
nonstandard = {
weu = {
rg = "${var.project}-container-registry-rg"
acr = replace("${var.project}-common-acr", "-", "")
}
}
}
6 changes: 6 additions & 0 deletions src/core/_modules/container_registry/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output "acr" {
value = {
id = module.container_registry.id
login_server = module.container_registry.login_server
}
}
6 changes: 6 additions & 0 deletions src/core/_modules/container_registry/resource_groups.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "azurerm_resource_group" "container_registry" {
name = local.nonstandard[var.location_short].rg
location = var.location

tags = var.tags
}
19 changes: 19 additions & 0 deletions src/core/_modules/container_registry/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
variable "project" {
type = string
description = "IO prefix, short environment and short location"
}

variable "location" {
type = string
description = "Azure region"
}

variable "location_short" {
type = string
description = "Azure region short name"
}

variable "tags" {
type = map(any)
description = "Resource tags"
}
1 change: 1 addition & 0 deletions src/core/prod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

| Name | Source | Version |
|------|--------|---------|
| <a name="module_container_registry"></a> [container\_registry](#module\_container\_registry) | ../_modules/container_registry | n/a |
| <a name="module_global"></a> [global](#module\_global) | ../_modules/global | n/a |
| <a name="module_networking_itn"></a> [networking\_itn](#module\_networking\_itn) | ../_modules/networking | n/a |
| <a name="module_networking_weu"></a> [networking\_weu](#module\_networking\_weu) | ../_modules/networking | n/a |
Expand Down
10 changes: 10 additions & 0 deletions src/core/prod/westeurope.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,13 @@ module "vnet_peering_weu" {
}
}
}

module "container_registry" {
source = "../_modules/container_registry"

location = data.azurerm_resource_group.vnet_weu.location
location_short = local.location_short[data.azurerm_resource_group.vnet_weu.location]
project = local.project_weu_legacy

tags = merge(local.tags, { Source = "https://github.com/pagopa/io-infra" })
}

0 comments on commit 239bc8d

Please sign in to comment.