Skip to content

Commit

Permalink
refactor web storage
Browse files Browse the repository at this point in the history
  • Loading branch information
kahlstrm committed Jan 24, 2024
1 parent f38d970 commit 3ce8d47
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 56 deletions.
11 changes: 2 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,9 @@ module "common" {
env_name = "prod"
resource_group_location = local.resource_group_location
}
module "web_storage" {
source = "./modules/web/storage"
resource_group_location = local.resource_group_location
resource_group_name = module.common.resource_group_name
}

module "web" {
source = "./modules/web/app"
source = "./modules/web"
resource_group_location = local.resource_group_location
resource_group_name = module.common.resource_group_name
app_service_plan_id = module.common.tikweb_app_plan_id
Expand All @@ -128,9 +124,6 @@ module "web" {
mongo_connection_string = module.keyvault.mongo_db_connection_string
google_oauth_client_id = module.keyvault.google_oauth_client_id
google_oauth_client_secret = module.keyvault.google_oauth_client_secret
storage_connection_string = module.web_storage.storage_connection_string
storage_container_name = module.web_storage.storage_container_name
storage_account_base_url = module.web_storage.storage_account_base_url
public_ilmo_url = "https://${module.ilmo.fqdn}"
}

Expand Down
17 changes: 17 additions & 0 deletions modules/storage_container/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "azurerm_storage_account" "storage_account" {
name = var.storage_account_name
resource_group_name = var.resource_group_name
location = var.resource_group_location
account_tier = "Standard"
account_replication_type = "LRS"
allow_nested_items_to_be_public = false
min_tls_version = "TLS1_2"
}


resource "azurerm_storage_container" "container" {
name = var.container_name
storage_account_name = azurerm_storage_account.storage_account.name
container_access_type = "private"

}
19 changes: 19 additions & 0 deletions modules/storage_container/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Storage

output "storage_account_name" {
value = azurerm_storage_account.storage_account.name
}
output "storage_connection_string" {
value = azurerm_storage_account.storage_account.primary_connection_string
sensitive = true
}
output "container_name" {
value = azurerm_storage_container.container.name
}
output "storage_account_base_url" {
value = azurerm_storage_account.storage_account.primary_blob_endpoint
}
output "storage_access_key" {
value = azurerm_storage_account.storage_account.primary_access_key
sensitive = true
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
variable "resource_group_name" {
variable "storage_account_name" {
type = string
}

variable "resource_group_name" {
type = string
}
variable "resource_group_location" {
type = string
}
variable "container_name" {
type = string

}
File renamed without changes.
13 changes: 10 additions & 3 deletions modules/web/app/main.tf → modules/web/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
locals {
payload_port = 3001
}
module "container" {
source = "../storage_container"
resource_group_location = var.resource_group_location
container_name = "media-${terraform.workspace}"
resource_group_name = var.resource_group_name
storage_account_name = "tikwebstorage${terraform.workspace}"
}
resource "random_password" "revalidation_key" {
length = 32
special = true
Expand Down Expand Up @@ -100,9 +107,9 @@ resource "azurerm_linux_web_app" "cms" {
PAYLOAD_DEFAULT_USER_PASSWORD = random_password.payload_password.result
WEBSITES_PORT = local.payload_port
PAYLOAD_PORT = local.payload_port
AZURE_STORAGE_CONNECTION_STRING = var.storage_connection_string
AZURE_STORAGE_CONTAINER_NAME = var.storage_container_name
AZURE_STORAGE_ACCOUNT_BASEURL = var.storage_account_base_url
AZURE_STORAGE_CONNECTION_STRING = module.container.storage_connection_string
AZURE_STORAGE_CONTAINER_NAME = module.container.container_name
AZURE_STORAGE_ACCOUNT_BASEURL = module.container.storage_account_base_url
GOOGLE_OAUTH_CLIENT_ID = var.google_oauth_client_id
GOOGLE_OAUTH_CLIENT_SECRET = var.google_oauth_client_secret
}
Expand Down
File renamed without changes.
17 changes: 0 additions & 17 deletions modules/web/storage/main.tf

This file was deleted.

15 changes: 0 additions & 15 deletions modules/web/storage/output.tf

This file was deleted.

11 changes: 0 additions & 11 deletions modules/web/app/variables.tf → modules/web/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,7 @@ variable "google_oauth_client_secret" {
type = string
sensitive = true
}
variable "storage_connection_string" {
type = string
sensitive = true
}

variable "storage_container_name" {
type = string
}

variable "storage_account_base_url" {
type = string
}
variable "public_ilmo_url" {
type = string

Expand Down

0 comments on commit 3ce8d47

Please sign in to comment.