-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CES-30] Move Redis-Common in Common TF config (#1178)
- Loading branch information
Showing
14 changed files
with
165 additions
and
167 deletions.
There are no files selected for viewing
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,9 @@ | ||
locals { | ||
nonstandard = { | ||
weu = { | ||
subnet = "rediscommon" | ||
redis_common = "${var.project}-redis-common" | ||
storage_account = replace(format("%s-stredisbackup", var.project), "-", "") | ||
} | ||
} | ||
} |
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,54 @@ | ||
resource "azurerm_redis_cache" "common" { | ||
name = try(local.nonstandard[var.location_short].redis_common, "${var.project}-common-redis-01") | ||
resource_group_name = var.resource_group_name | ||
location = var.location | ||
capacity = 2 | ||
shard_count = 4 | ||
family = "P" | ||
sku_name = "Premium" | ||
subnet_id = azurerm_subnet.redis.id | ||
public_network_access_enabled = true | ||
redis_version = "6" | ||
zones = null | ||
|
||
redis_configuration { | ||
authentication_enabled = true | ||
rdb_backup_enabled = true | ||
rdb_backup_frequency = 60 | ||
rdb_backup_max_snapshot_count = 1 | ||
rdb_storage_connection_string = module.redis_common_backup_zrs.primary_blob_connection_string | ||
data_persistence_authentication_method = "SAS" | ||
storage_account_subscription_id = "ec285037-c673-4f58-b594-d7c480da4e8b" | ||
} | ||
|
||
patch_schedule { | ||
day_of_week = "Sunday" | ||
start_hour_utc = 23 | ||
} | ||
patch_schedule { | ||
day_of_week = "Monday" | ||
start_hour_utc = 23 | ||
} | ||
patch_schedule { | ||
day_of_week = "Tuesday" | ||
start_hour_utc = 23 | ||
} | ||
patch_schedule { | ||
day_of_week = "Wednesday" | ||
start_hour_utc = 23 | ||
} | ||
patch_schedule { | ||
day_of_week = "Thursday" | ||
start_hour_utc = 23 | ||
} | ||
|
||
# NOTE: There's a bug in the Redis API where the original storage connection string isn't being returned, | ||
# which is being tracked here [https://github.com/Azure/azure-rest-api-specs/issues/3037]. | ||
# At first import/creation, apply without the lifecyle, add it later. Connection string | ||
# should be about the blob storage | ||
lifecycle { | ||
ignore_changes = [redis_configuration[0].rdb_storage_connection_string] | ||
} | ||
|
||
tags = var.tags | ||
} |
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,17 @@ | ||
module "redis_common_backup_zrs" { | ||
source = "github.com/pagopa/terraform-azurerm-v3//storage_account?ref=v8.27.0" | ||
|
||
name = try(local.nonstandard[var.location_short].storage_account, "${var.project}-redis-common-st-01") | ||
account_kind = "StorageV2" | ||
account_tier = "Premium" | ||
access_tier = "Hot" | ||
account_replication_type = "ZRS" | ||
resource_group_name = var.resource_group_name | ||
location = var.location | ||
advanced_threat_protection = true | ||
use_legacy_defender_version = false | ||
allow_nested_items_to_be_public = false | ||
public_network_access_enabled = true | ||
|
||
tags = var.tags | ||
} |
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,7 @@ | ||
resource "azurerm_subnet" "redis" { | ||
name = try(local.nonstandard[var.location_short].subnet, "${var.project}-redis-snet-01") | ||
address_prefixes = [var.cidr_subnet_redis_common] | ||
resource_group_name = var.vnet_common.resource_group_name | ||
virtual_network_name = var.vnet_common.name | ||
private_endpoint_network_policies = "Enabled" | ||
} |
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,38 @@ | ||
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" | ||
} | ||
|
||
variable "resource_group_name" { | ||
type = string | ||
description = "Resource group" | ||
} | ||
|
||
variable "vnet_common" { | ||
type = object({ | ||
id = string | ||
name = string | ||
address_space = list(string) | ||
resource_group_name = string | ||
}) | ||
description = "Information of the common VNet" | ||
} | ||
|
||
variable "cidr_subnet_redis_common" { | ||
type = string | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.