Skip to content

Commit

Permalink
[EC-217] Move EUCovidCert storage accounts to their own module (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty93 authored Mar 22, 2024
1 parent ab21c6f commit caa8d56
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
| <a name="module_db_subscription_profileemails_container"></a> [db\_subscription\_profileemails\_container](#module\_db\_subscription\_profileemails\_container) | git::https://github.com/pagopa/terraform-azurerm-v3.git//cosmosdb_sql_container | v7.61.0 |
| <a name="module_dns_forwarder"></a> [dns\_forwarder](#module\_dns\_forwarder) | git::https://github.com/pagopa/terraform-azurerm-v3.git//dns_forwarder | v7.61.0 |
| <a name="module_dns_forwarder_snet"></a> [dns\_forwarder\_snet](#module\_dns\_forwarder\_snet) | git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet | v7.61.0 |
| <a name="module_eucovidcert_storage_account"></a> [eucovidcert\_storage\_account](#module\_eucovidcert\_storage\_account) | git::https://github.com/pagopa/terraform-azurerm-v3.git//storage_account | v7.61.0 |
| <a name="module_event_hub"></a> [event\_hub](#module\_event\_hub) | git::https://github.com/pagopa/terraform-azurerm-v3.git//eventhub | v7.61.0 |
| <a name="module_eventhub_snet"></a> [eventhub\_snet](#module\_eventhub\_snet) | git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet | v7.61.0 |
| <a name="module_function_admin"></a> [function\_admin](#module\_function\_admin) | git::https://github.com/pagopa/terraform-azurerm-v3.git//function_app | v7.61.0 |
Expand Down Expand Up @@ -500,6 +499,7 @@
| [azurerm_storage_account.lollipop_assertions_storage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source |
| [azurerm_storage_account.notifications](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source |
| [azurerm_storage_account.push_notifications_storage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source |
| [azurerm_storage_account.steucovid](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source |
| [azurerm_storage_account.storage_apievents](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source |
| [azurerm_storage_account.userbackups](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source |
| [azurerm_storage_account.userdatadownload](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source |
Expand Down
28 changes: 6 additions & 22 deletions src/core/function_eucovidcert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,9 @@ data "azurerm_resource_group" "eucovidcert_rg" {
name = format("%s-rg-eucovidcert", local.project)
}

#
# STORAGE
#
module "eucovidcert_storage_account" {
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//storage_account?ref=v7.61.0"

name = "${replace(local.project, "-", "")}steucovidcert"
account_kind = "StorageV2"
account_tier = "Standard"
access_tier = "Hot"
blob_versioning_enabled = false
account_replication_type = "GZRS"
resource_group_name = data.azurerm_resource_group.eucovidcert_rg.name
location = data.azurerm_resource_group.eucovidcert_rg.location
advanced_threat_protection = false
allow_nested_items_to_be_public = false
public_network_access_enabled = true

tags = var.tags
data "azurerm_storage_account" "steucovid" {
name = "${replace(local.project, "-", "")}steucovidcert"
resource_group_name = "${local.project}-rg-eucovidcert"
}

#
Expand Down Expand Up @@ -132,11 +116,11 @@ locals {
DGC_LOAD_TEST_SERVER_CA = trimspace(data.azurerm_key_vault_secret.fn_eucovidcert_DGC_LOAD_TEST_SERVER_CA.value)

// Events configs
EventsQueueStorageConnection = module.eucovidcert_storage_account.primary_connection_string
EventsQueueStorageConnection = data.azurerm_storage_account.steucovid.primary_connection_string
EUCOVIDCERT_PROFILE_CREATED_QUEUE_NAME = "eucovidcert-profile-created"
QueueStorageConnection = module.eucovidcert_storage_account.primary_connection_string
QueueStorageConnection = data.azurerm_storage_account.steucovid.primary_connection_string
EUCOVIDCERT_NOTIFY_NEW_PROFILE_QUEUE_NAME = "notify-new-profile"
TableStorageConnection = module.eucovidcert_storage_account.primary_connection_string
TableStorageConnection = data.azurerm_storage_account.steucovid.primary_connection_string
EUCOVIDCERT_TRACE_NOTIFY_NEW_PROFILE_TABLE_NAME = "TraceNotifyNewProfile"

FNSERVICES_API_URL = join(",", formatlist("https://%s/api/v1", module.function_services.*.default_hostname))
Expand Down
8 changes: 8 additions & 0 deletions src/domains/eucovidcert/_modules/storage_accounts/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {

required_providers {
azurerm = {
source = "hashicorp/azurerm"
}
}
}
7 changes: 7 additions & 0 deletions src/domains/eucovidcert/_modules/storage_accounts/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "storage_account_eucovidcert" {
value = {
id = module.storage_account_eucovidcert.id
name = module.storage_account_eucovidcert.name
resource_group_name = var.resource_group_name
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module "storage_account_eucovidcert" {
source = "github.com/pagopa/terraform-azurerm-v3//storage_account?ref=v7.69.1"

name = "${replace(var.project, "-", "")}steucovidcert"
account_kind = "StorageV2"
account_tier = "Standard"
access_tier = "Hot"
blob_versioning_enabled = false
account_replication_type = "GZRS"
resource_group_name = var.resource_group_name
location = var.location
advanced_threat_protection = false
allow_nested_items_to_be_public = false
public_network_access_enabled = true

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

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

variable "tags" {
type = map(any)
description = "Resource tags"
}

variable "resource_group_name" {
type = string
description = "Name of the resource group where resources will be created"
}
53 changes: 39 additions & 14 deletions src/domains/eucovidcert/prod/westeurope/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/domains/eucovidcert/prod/westeurope/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
| Name | Source | Version |
|------|--------|---------|
| <a name="module_resource_groups"></a> [resource\_groups](#module\_resource\_groups) | ../../_modules/resource_groups | n/a |
| <a name="module_storage_accounts"></a> [storage\_accounts](#module\_storage\_accounts) | ../../_modules/storage_accounts | n/a |

## Resources

Expand Down
9 changes: 9 additions & 0 deletions src/domains/eucovidcert/prod/westeurope/storage_accounts.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module "storage_accounts" {
source = "../../_modules/storage_accounts"

location = local.location
project = local.project
resource_group_name = module.resource_groups.resource_group_eucovidcert.name

tags = local.tags
}

0 comments on commit caa8d56

Please sign in to comment.