-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
terraform: move caddy state to persistent
Move caddy state disk to persistent. Binary-cache vm stores let's encrypt certificates and data on the caddy state disk. This state disk needs to be stored in 'persistent' data, otherwise there will be issues with certificate authority rate limits when development environments are deployed and consequently destroyed. Signed-off-by: Henri Rosten <[email protected]>
- Loading branch information
1 parent
43ebf4a
commit 211229f
Showing
6 changed files
with
141 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# SPDX-FileCopyrightText: 2024 Technology Innovation Institute (TII) | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
} | ||
} | ||
} | ||
|
||
################################################################################ | ||
|
||
terraform { | ||
# Backend for storing terraform state (see ../../state-storage) | ||
backend "azurerm" { | ||
resource_group_name = "ghaf-infra-state" | ||
storage_account_name = "ghafinfratfstatestorage" | ||
container_name = "ghaf-infra-tfstate-container" | ||
key = "ghaf-infra-persistent.tfstate" | ||
} | ||
} | ||
|
||
################################################################################ | ||
|
||
# Variables | ||
variable "location" { | ||
type = string | ||
default = "northeurope" | ||
description = "Azure region into which the resources will be deployed" | ||
} | ||
variable "persistent_resource_group" { | ||
type = string | ||
default = "ghaf-infra-persistent-eun" | ||
description = "Parent resource group name" | ||
} | ||
|
||
locals { | ||
# Raise an error if workspace is 'default', | ||
# this is a workaround to missing asserts in terraform: | ||
assert_workspace_not_default = regex( | ||
(terraform.workspace == "default") ? | ||
"((Force invalid regex pattern)\n\nERROR: workspace 'default' is not allowed" : "", "") | ||
|
||
# Sanitize workspace name: | ||
ws = substr(replace(lower(terraform.workspace), "/[^a-z0-9]/", ""), 0, 16) | ||
} | ||
|
||
# Data source to access persistent resource group (see ../main.tf) | ||
data "azurerm_resource_group" "persistent" { | ||
name = var.persistent_resource_group | ||
} | ||
|
||
# Current signed-in user | ||
data "azurerm_client_config" "current" {} | ||
|
||
|
||
################################################################################ | ||
|
||
# Resources | ||
|
||
resource "azurerm_managed_disk" "binary_cache_caddy_state" { | ||
name = "binary-cache-vm-caddy-state-${local.ws}" | ||
resource_group_name = data.azurerm_resource_group.persistent.name | ||
location = data.azurerm_resource_group.persistent.location | ||
storage_account_type = "Standard_LRS" | ||
create_option = "Empty" | ||
disk_size_gb = 1 | ||
} | ||
|
||
################################################################################ |
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