updating infrastructure
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
locals {
|
||||
app_name = {
|
||||
test = "flying-api-test"
|
||||
prod = "flying-api-prod"
|
||||
}
|
||||
|
||||
container_image = {
|
||||
test = "docker.io/noahspan/flying-api:v2.0.0-beta"
|
||||
prod = "docker.io/noahspan/flying-api:v2.0.0-beta"
|
||||
}
|
||||
|
||||
container_name = {
|
||||
test = "flying-api-test"
|
||||
prod = "flying-api-prod"
|
||||
}
|
||||
|
||||
custom_domain_count = {
|
||||
test = 0
|
||||
prod = 0
|
||||
}
|
||||
|
||||
ingress_external_enabled = {
|
||||
test = true
|
||||
prod = true
|
||||
}
|
||||
|
||||
ingress_target_port = {
|
||||
test = 3000
|
||||
prod = 3000
|
||||
}
|
||||
|
||||
ingress_transport = {
|
||||
test = "auto"
|
||||
prod = "auto"
|
||||
}
|
||||
|
||||
traffic_weight_percentage = {
|
||||
test = 100
|
||||
prod = 100
|
||||
}
|
||||
|
||||
template_min_replicas = {
|
||||
test = 0
|
||||
prod = 0
|
||||
}
|
||||
|
||||
template_max_replicas = {
|
||||
test = 2
|
||||
prod = 2
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
output "app_name" {
|
||||
value = local.app_name[var.environment]
|
||||
}
|
||||
|
||||
output "container_image" {
|
||||
value = local.container_image[var.environment]
|
||||
}
|
||||
|
||||
output "container_name" {
|
||||
value = local.container_name[var.environment]
|
||||
}
|
||||
|
||||
output "custom_domain_count" {
|
||||
value = local.custom_domain_count[var.environment]
|
||||
}
|
||||
|
||||
output "ingress_external_enabled" {
|
||||
value = local.ingress_external_enabled[var.environment]
|
||||
}
|
||||
|
||||
output "ingress_target_port" {
|
||||
value = local.ingress_target_port[var.environment]
|
||||
}
|
||||
|
||||
output "ingress_transport" {
|
||||
value = local.ingress_transport[var.environment]
|
||||
}
|
||||
|
||||
output "traffic_weight_percentage" {
|
||||
value = local.traffic_weight_percentage[var.environment]
|
||||
}
|
||||
|
||||
output "template_min_replicas" {
|
||||
value = local.template_min_replicas[var.environment]
|
||||
}
|
||||
|
||||
output "template_max_replicas" {
|
||||
value = local.template_max_replicas[var.environment]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
variable "environment" {}
|
||||
@@ -1,56 +0,0 @@
|
||||
locals {
|
||||
app_name = {
|
||||
test = "flying-test"
|
||||
prod = "flying-prod"
|
||||
}
|
||||
|
||||
container_app_environment_name = {
|
||||
test = "noahspan-test"
|
||||
prod = "noahspan-prod"
|
||||
}
|
||||
|
||||
container_image = {
|
||||
test = "noahspan/flying-app:v2.0.0-alpha"
|
||||
prod = "noahspan/flying-app:v2.0.0-alpha"
|
||||
}
|
||||
|
||||
container_name = {
|
||||
test = "flying-app-test"
|
||||
prod = "flying-app-prod"
|
||||
}
|
||||
|
||||
custom_domain_count = {
|
||||
test = 0
|
||||
prod = 1
|
||||
}
|
||||
|
||||
ingress_external_enabled = {
|
||||
test = true
|
||||
prod = true
|
||||
}
|
||||
|
||||
ingress_target_port = {
|
||||
test = 8080
|
||||
prod = 8080
|
||||
}
|
||||
|
||||
ingress_transport = {
|
||||
test = "auto"
|
||||
prod = "auto"
|
||||
}
|
||||
|
||||
traffic_weight_percentage = {
|
||||
test = 100
|
||||
prod = 100
|
||||
}
|
||||
|
||||
template_min_replicas = {
|
||||
test = 0
|
||||
prod = 0
|
||||
}
|
||||
|
||||
template_max_replicas = {
|
||||
test = 2
|
||||
prod = 2
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
output "app_name" {
|
||||
value = local.app_name[var.environment]
|
||||
}
|
||||
|
||||
output "container_app_environment_name" {
|
||||
value = local.container_app_environment_name[var.environment]
|
||||
}
|
||||
|
||||
output "container_image" {
|
||||
value = local.container_image[var.environment]
|
||||
}
|
||||
|
||||
output "container_name" {
|
||||
value = local.container_name[var.environment]
|
||||
}
|
||||
|
||||
output "custom_domain_count" {
|
||||
value = local.custom_domain_count[var.environment]
|
||||
}
|
||||
|
||||
output "ingress_external_enabled" {
|
||||
value = local.ingress_external_enabled[var.environment]
|
||||
}
|
||||
|
||||
output "ingress_target_port" {
|
||||
value = local.ingress_target_port[var.environment]
|
||||
}
|
||||
|
||||
output "ingress_transport" {
|
||||
value = local.ingress_transport[var.environment]
|
||||
}
|
||||
|
||||
output "traffic_weight_percentage" {
|
||||
value = local.traffic_weight_percentage[var.environment]
|
||||
}
|
||||
|
||||
output "template_min_replicas" {
|
||||
value = local.template_min_replicas[var.environment]
|
||||
}
|
||||
|
||||
output "template_max_replicas" {
|
||||
value = local.template_max_replicas[var.environment]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
variable "environment" {}
|
||||
@@ -1,9 +1,36 @@
|
||||
module "app" {
|
||||
source = "./app"
|
||||
environment = var.environment
|
||||
}
|
||||
locals {
|
||||
app_name = {
|
||||
test = "flying-test"
|
||||
prod = "flying-prod"
|
||||
}
|
||||
|
||||
module "storage" {
|
||||
source = "./storage"
|
||||
environment = var.environment
|
||||
}
|
||||
container_image = {
|
||||
test = "noahspan/flying-app:v2.0.0-alpha"
|
||||
prod = "noahspan/flying-app:v2.0.0-alpha"
|
||||
}
|
||||
|
||||
container_name = {
|
||||
test = "flying-container-test"
|
||||
prod = "flying-container-prod"
|
||||
}
|
||||
|
||||
container_app_environment_name = {
|
||||
test = "noahspan-test"
|
||||
prod = "noahspan-prod"
|
||||
}
|
||||
|
||||
storage_account_name = {
|
||||
test = "noahspanflyingtest"
|
||||
prod = "noahspanflyingprod"
|
||||
}
|
||||
|
||||
storage_account_containers = {
|
||||
test = ["tracks"]
|
||||
prod = ["tracks"]
|
||||
}
|
||||
|
||||
storage_account_storage_shares = {
|
||||
test = ["flying-test-database-share"]
|
||||
prod = ["flying-prod-database-share"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
output "app" {
|
||||
value = module.app
|
||||
output "app_name" {
|
||||
value = local.app_name[var.environment]
|
||||
}
|
||||
|
||||
output "storage" {
|
||||
value = module.storage
|
||||
output "container_image" {
|
||||
value = local.container_image[var.environment]
|
||||
}
|
||||
|
||||
output "container_name" {
|
||||
value = local.container_name[var.environment]
|
||||
}
|
||||
|
||||
output "container_app_environment_name" {
|
||||
value = local.container_app_environment_name[var.environment]
|
||||
}
|
||||
|
||||
output "storage_account_name" {
|
||||
value = local.storage_account_name[var.environment]
|
||||
}
|
||||
|
||||
output "storage_account_containers" {
|
||||
value = local.storage_account_containers[var.environment]
|
||||
}
|
||||
|
||||
output "storage_account_storage_shares" {
|
||||
value = local.storage_account_storage_shares[var.environment]
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
locals {
|
||||
account_name = {
|
||||
test = "noahspanflyingtest"
|
||||
prod = "noahspanflyingprod"
|
||||
}
|
||||
|
||||
containers = {
|
||||
test = ["tracks"]
|
||||
prod = ["tracks"]
|
||||
}
|
||||
|
||||
shares = {
|
||||
test = ["flying-test-files"]
|
||||
prod = ["flying-prod-files"]
|
||||
}
|
||||
|
||||
tables = {
|
||||
test = ["logs", "pilots"]
|
||||
prod = ["logs", "pilots"]
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
output "account_name" {
|
||||
value = local.account_name[var.environment]
|
||||
}
|
||||
|
||||
output "containers" {
|
||||
value = local.containers[var.environment]
|
||||
}
|
||||
|
||||
output "shares" {
|
||||
value = local.shares[var.environment]
|
||||
}
|
||||
|
||||
output "tables" {
|
||||
value = local.tables[var.environment]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
variable "environment" {}
|
||||
@@ -1,12 +1,12 @@
|
||||
resource "azurerm_container_app" "container_app" {
|
||||
name = module.environment.app.app_name
|
||||
name = module.environment.app_name
|
||||
container_app_environment_id = data.azurerm_container_app_environment.container_app_environment.id
|
||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||
revision_mode = "Single"
|
||||
|
||||
template {
|
||||
min_replicas = module.environment.app.template_min_replicas
|
||||
max_replicas = module.environment.app.template_max_replicas
|
||||
min_replicas = 0
|
||||
max_replicas = 2
|
||||
|
||||
init_container {
|
||||
args = ["restore", "-if-db-not-exists", "-if-replica-exists", "/var/lib/data/flying.db"]
|
||||
@@ -60,9 +60,9 @@ resource "azurerm_container_app" "container_app" {
|
||||
|
||||
container {
|
||||
cpu = 0.25
|
||||
image = module.environment.app.container_image
|
||||
image = "noahspan/flying-app:v2.0.0-alpha"
|
||||
memory = "0.5Gi"
|
||||
name = module.environment.app.container_name
|
||||
name = "flying"
|
||||
|
||||
env {
|
||||
name = "AZURE_STORAGE_CONNECTION_STRING"
|
||||
@@ -111,7 +111,7 @@ resource "azurerm_container_app" "container_app" {
|
||||
|
||||
volume {
|
||||
name = "backup"
|
||||
storage_name = azurerm_container_app_environment_storage.container_app_environment_storage_backup.name
|
||||
storage_name = azurerm_container_app_environment_storage.container_app_environment_storage_database.name
|
||||
storage_type = "AzureFile"
|
||||
}
|
||||
|
||||
@@ -123,13 +123,13 @@ resource "azurerm_container_app" "container_app" {
|
||||
|
||||
ingress {
|
||||
allow_insecure_connections = false
|
||||
external_enabled = module.environment.app.ingress_external_enabled
|
||||
target_port = module.environment.app.ingress_target_port
|
||||
transport = module.environment.app.ingress_transport
|
||||
external_enabled = true
|
||||
target_port = 3000
|
||||
transport = "auto"
|
||||
|
||||
traffic_weight {
|
||||
latest_revision = true
|
||||
percentage = module.environment.app.traffic_weight_percentage
|
||||
percentage = 100
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
resource "azurerm_container_app_environment_storage" "container_app_environment_storage_backup" {
|
||||
name = "${module.environment.app.app_name}-backup"
|
||||
resource "azurerm_container_app_environment_storage" "container_app_environment_storage_database" {
|
||||
name = "${module.environment.app_name}-database"
|
||||
container_app_environment_id = data.azurerm_container_app_environment.container_app_environment.id
|
||||
account_name = azurerm_storage_account.storage_account.name
|
||||
share_name = azurerm_storage_share.backup_storage_share.name
|
||||
share_name = azurerm_storage_share.storage_share[0].name
|
||||
access_key = azurerm_storage_account.storage_account.primary_access_key
|
||||
access_mode = "ReadOnly"
|
||||
}
|
||||
@@ -5,6 +5,6 @@ data "azurerm_resource_group" "resource_group" {
|
||||
}
|
||||
|
||||
data "azurerm_container_app_environment" "container_app_environment" {
|
||||
name = module.environment.app.container_app_environment_name
|
||||
name = module.environment.container_app_environment_name
|
||||
resource_group_name = var.RESOURCE_GROUP_NAME
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
resource "azurerm_storage_account" "storage_account" {
|
||||
name = module.environment.storage.account_name
|
||||
name = module.environment.storage_account_name
|
||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||
location = data.azurerm_resource_group.resource_group.location
|
||||
account_tier = "Standard"
|
||||
@@ -7,13 +7,15 @@ resource "azurerm_storage_account" "storage_account" {
|
||||
}
|
||||
|
||||
resource "azurerm_storage_container" "storage_container" {
|
||||
name = "tracks"
|
||||
count = length(module.environment.storage_account_containers)
|
||||
name = module.environment.storage_account_containers[count.index]
|
||||
storage_account_id = azurerm_storage_account.storage_account.id
|
||||
container_access_type = "private"
|
||||
}
|
||||
|
||||
resource "azurerm_storage_share" "backup_storage_share" {
|
||||
name = "${module.environment.app.app_name}-backup-storage-share"
|
||||
resource "azurerm_storage_share" "storage_share" {
|
||||
count = length(module.environment.storage_account_storage_shares)
|
||||
name = module.environment.storage_account_storage_shares[count.index]
|
||||
quota = 50
|
||||
storage_account_name = azurerm_storage_account.storage_account.name
|
||||
}
|
||||
Reference in New Issue
Block a user