Updating terraform
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
# Flying API
|
||||||
|
|
||||||
|
An API for the Flying app.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Flying
|
||||||
|
|
||||||
|
A pilot's logbook for tracking flight hours.
|
||||||
@@ -5,8 +5,8 @@ locals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container_app_app_container_image = {
|
container_app_app_container_image = {
|
||||||
test = "noahspan/flying-app:v0.0.1"
|
test = "noahspan/flying-app:v1.0.0"
|
||||||
prod = "noahspan/flying-app:v0.0.1"
|
prod = "noahspan/flying-app:v1.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
container_app_app_container_name = {
|
container_app_app_container_name = {
|
||||||
@@ -20,8 +20,8 @@ locals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container_app_api_container_image = {
|
container_app_api_container_image = {
|
||||||
test = "noahspan/flying-api:v0.0.1"
|
test = "noahspan/flying-api:v1.0.0"
|
||||||
prod = "noahspan/flying-api:v0.0.1"
|
prod = "noahspan/flying-api:v1.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
container_app_api_container_name = {
|
container_app_api_container_name = {
|
||||||
@@ -29,11 +29,6 @@ locals {
|
|||||||
prod = "flying-api-prod"
|
prod = "flying-api-prod"
|
||||||
}
|
}
|
||||||
|
|
||||||
container_app_api_dapr_app_id = {
|
|
||||||
test = "flyingapitest"
|
|
||||||
prod = "flyingpapiprod"
|
|
||||||
}
|
|
||||||
|
|
||||||
container_app_environment_name = {
|
container_app_environment_name = {
|
||||||
test = "flying-test"
|
test = "flying-test"
|
||||||
prod = "flying-prod"
|
prod = "flying-prod"
|
||||||
@@ -63,4 +58,9 @@ locals {
|
|||||||
test = "noahspanflyingtest"
|
test = "noahspanflyingtest"
|
||||||
prod = "noahspanflyingprod"
|
prod = "noahspanflyingprod"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storage_tables = {
|
||||||
|
test = ["logs", "pilots"]
|
||||||
|
prod = ["logs", "pilots"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,10 +22,6 @@ output "container_app_api_container_name" {
|
|||||||
value = local.container_app_api_container_name[var.environment]
|
value = local.container_app_api_container_name[var.environment]
|
||||||
}
|
}
|
||||||
|
|
||||||
output "container_app_api_dapr_app_id" {
|
|
||||||
value = local.container_app_api_dapr_app_id[var.environment]
|
|
||||||
}
|
|
||||||
|
|
||||||
output "container_app_environment_name" {
|
output "container_app_environment_name" {
|
||||||
value = local.container_app_environment_name[var.environment]
|
value = local.container_app_environment_name[var.environment]
|
||||||
}
|
}
|
||||||
@@ -49,3 +45,7 @@ output "pilots_feature_flag_active" {
|
|||||||
output "storage_account_name" {
|
output "storage_account_name" {
|
||||||
value = local.storage_account_name[var.environment]
|
value = local.storage_account_name[var.environment]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "storage_tables" {
|
||||||
|
value = local.storage_tables[var.environment]
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
data "azurerm_dns_zone" "dns_zone" {
|
|
||||||
name = var.DOMAIN_NAME
|
|
||||||
}
|
|
||||||
|
|
||||||
data "azurerm_resource_group" "dns_zone_resource_group" {
|
|
||||||
name = "noahspan"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_dns_txt_record" "dns_txt_record" {
|
|
||||||
count = module.environment.custom_domain_count
|
|
||||||
name = "asuid.${var.APP_SUBDOMAIN_NAME}"
|
|
||||||
resource_group_name = data.azurerm_resource_group.dns_zone_resource_group.name
|
|
||||||
zone_name = data.azurerm_dns_zone.dns_zone.name
|
|
||||||
ttl = 14400
|
|
||||||
|
|
||||||
record {
|
|
||||||
value = azurerm_container_app.container_app_app.custom_domain_verification_id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,159 +1,183 @@
|
|||||||
data "azurerm_client_config" "current" {
|
# data "azurerm_client_config" "current" {
|
||||||
}
|
# }
|
||||||
|
|
||||||
resource "azurerm_log_analytics_workspace" "log_analytics_workspace" {
|
# resource "azurerm_log_analytics_workspace" "log_analytics_workspace" {
|
||||||
name = module.environment.log_analytics_workspace_name
|
# name = module.environment.log_analytics_workspace_name
|
||||||
location = data.azurerm_resource_group.resource_group.location
|
# location = data.azurerm_resource_group.resource_group.location
|
||||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
# resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||||
sku = "PerGB2018"
|
# sku = "PerGB2018"
|
||||||
retention_in_days = 30
|
# retention_in_days = 30
|
||||||
}
|
# }
|
||||||
|
|
||||||
resource "azurerm_container_app_environment" "container_app_environment" {
|
# resource "azurerm_container_app_environment" "container_app_environment" {
|
||||||
name = module.environment.container_app_environment_name
|
# name = module.environment.container_app_environment_name
|
||||||
location = data.azurerm_resource_group.resource_group.location
|
# location = data.azurerm_resource_group.resource_group.location
|
||||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
# resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||||
log_analytics_workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id
|
# log_analytics_workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id
|
||||||
}
|
# }
|
||||||
|
|
||||||
resource "azurerm_container_app" "container_app_api" {
|
# resource "azurerm_container_app" "container_app_api" {
|
||||||
name = module.environment.container_app_api_name
|
# name = module.environment.container_app_api_name
|
||||||
container_app_environment_id = azurerm_container_app_environment.container_app_environment.id
|
# container_app_environment_id = azurerm_container_app_environment.container_app_environment.id
|
||||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
# resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||||
revision_mode = "Single"
|
# revision_mode = "Single"
|
||||||
|
|
||||||
registry {
|
# registry {
|
||||||
server = "index.docker.io"
|
# server = "index.docker.io"
|
||||||
username = var.DOCKER_IO_USERNAME
|
# username = var.DOCKER_IO_USERNAME
|
||||||
password_secret_name = "docker-io-password"
|
# password_secret_name = "docker-io-password"
|
||||||
}
|
# }
|
||||||
|
|
||||||
template {
|
# template {
|
||||||
min_replicas = 0
|
# min_replicas = 0
|
||||||
max_replicas = 2
|
# max_replicas = 2
|
||||||
|
|
||||||
container {
|
# container {
|
||||||
name = module.environment.container_app_api_container_name
|
# name = module.environment.container_app_api_container_name
|
||||||
image = module.environment.container_app_api_container_image
|
# image = module.environment.container_app_api_container_image
|
||||||
cpu = 0.25
|
# cpu = 0.25
|
||||||
memory = "0.5Gi"
|
# memory = "0.5Gi"
|
||||||
|
|
||||||
env {
|
# env {
|
||||||
name = "AZURE_STORAGE_CONNECTION_STRING"
|
# name = "AZURE_STORAGE_CONNECTION_STRING"
|
||||||
secret_name = "azure-storage-connection-string"
|
# secret_name = "azure-storage-connection-string"
|
||||||
}
|
# }
|
||||||
|
|
||||||
env {
|
# env {
|
||||||
name = "CLIENT_ID"
|
# name = "CLIENT_ID"
|
||||||
secret_name = "client-id"
|
# secret_name = "client-id"
|
||||||
}
|
# }
|
||||||
|
|
||||||
env {
|
# env {
|
||||||
name = "CLIENT_SECRET"
|
# name = "CLIENT_SECRET"
|
||||||
secret_name = "client-secret"
|
# secret_name = "client-secret"
|
||||||
}
|
# }
|
||||||
|
|
||||||
env {
|
# env {
|
||||||
name = "TENANT_ID"
|
# name = "TENANT_ID"
|
||||||
secret_name = "tenant-id"
|
# secret_name = "tenant-id"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
ingress {
|
# ingress {
|
||||||
allow_insecure_connections = false
|
# allow_insecure_connections = false
|
||||||
external_enabled = true
|
# external_enabled = true
|
||||||
target_port = 3000
|
# target_port = 3000
|
||||||
transport = "auto"
|
# transport = "auto"
|
||||||
|
|
||||||
traffic_weight {
|
# traffic_weight {
|
||||||
latest_revision = true
|
# latest_revision = true
|
||||||
percentage = 100
|
# percentage = 100
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
secret {
|
# secret {
|
||||||
name = "docker-io-password"
|
# name = "docker-io-password"
|
||||||
value = var.DOCKER_IO_PASSWORD
|
# value = var.DOCKER_IO_PASSWORD
|
||||||
}
|
# }
|
||||||
|
|
||||||
secret {
|
# secret {
|
||||||
name = "azure-storage-connection-string"
|
# name = "azure-storage-connection-string"
|
||||||
value = azurerm_storage_account.storage_account.primary_connection_string
|
# value = azurerm_storage_account.storage_account.primary_connection_string
|
||||||
}
|
# }
|
||||||
|
|
||||||
secret {
|
# secret {
|
||||||
name = "client-id"
|
# name = "client-id"
|
||||||
value = var.CLIENT_ID
|
# value = var.CLIENT_ID
|
||||||
}
|
# }
|
||||||
|
|
||||||
secret {
|
# secret {
|
||||||
name = "client-secret"
|
# name = "client-secret"
|
||||||
value = var.CLIENT_SECRET
|
# value = var.CLIENT_SECRET
|
||||||
}
|
# }
|
||||||
|
|
||||||
secret {
|
# secret {
|
||||||
name = "tenant-id"
|
# name = "tenant-id"
|
||||||
value = var.TENANT_ID
|
# value = var.TENANT_ID
|
||||||
}
|
# }
|
||||||
|
|
||||||
lifecycle {
|
# lifecycle {
|
||||||
ignore_changes = [ template[0].container[0].image ]
|
# ignore_changes = [ template[0].container[0].image ]
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
resource "azurerm_container_app" "container_app_app" {
|
# resource "azurerm_container_app" "container_app_app" {
|
||||||
name = module.environment.container_app_app_name
|
# name = module.environment.container_app_app_name
|
||||||
container_app_environment_id = azurerm_container_app_environment.container_app_environment.id
|
# container_app_environment_id = azurerm_container_app_environment.container_app_environment.id
|
||||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
# resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||||
revision_mode = "Single"
|
# revision_mode = "Single"
|
||||||
|
|
||||||
registry {
|
# registry {
|
||||||
server = "index.docker.io"
|
# server = "index.docker.io"
|
||||||
username = var.DOCKER_IO_USERNAME
|
# username = var.DOCKER_IO_USERNAME
|
||||||
password_secret_name = "docker-io-password"
|
# password_secret_name = "docker-io-password"
|
||||||
}
|
# }
|
||||||
|
|
||||||
template {
|
# template {
|
||||||
min_replicas = 0
|
# min_replicas = 0
|
||||||
max_replicas = 2
|
# max_replicas = 2
|
||||||
|
|
||||||
container {
|
# container {
|
||||||
name = module.environment.container_app_app_container_name
|
# name = module.environment.container_app_app_container_name
|
||||||
image = module.environment.container_app_app_container_image
|
# image = module.environment.container_app_app_container_image
|
||||||
cpu = 0.25
|
# cpu = 0.25
|
||||||
memory = "0.5Gi"
|
# memory = "0.5Gi"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
ingress {
|
# ingress {
|
||||||
allow_insecure_connections = false
|
# allow_insecure_connections = false
|
||||||
external_enabled = true
|
# external_enabled = true
|
||||||
target_port = 8080
|
# target_port = 8080
|
||||||
transport = "auto"
|
# transport = "auto"
|
||||||
|
|
||||||
traffic_weight {
|
# traffic_weight {
|
||||||
latest_revision = true
|
# latest_revision = true
|
||||||
percentage = 100
|
# percentage = 100
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
secret {
|
# secret {
|
||||||
name = "docker-io-password"
|
# name = "docker-io-password"
|
||||||
value = var.DOCKER_IO_PASSWORD
|
# value = var.DOCKER_IO_PASSWORD
|
||||||
}
|
# }
|
||||||
|
|
||||||
lifecycle {
|
# lifecycle {
|
||||||
ignore_changes = [ template[0].container[0].image ]
|
# ignore_changes = [ template[0].container[0].image ]
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
resource "azurerm_container_app_custom_domain" "custom_domain" {
|
# resource "azurerm_container_app_custom_domain" "custom_domain" {
|
||||||
count = module.environment.custom_domain_count
|
# count = module.environment.custom_domain_count
|
||||||
name = trimsuffix(trimprefix(azurerm_dns_txt_record.dns_txt_record[0].fqdn, "asuid."), ".")
|
# name = trimsuffix(trimprefix(azurerm_dns_txt_record.dns_txt_record[0].fqdn, "asuid."), ".")
|
||||||
container_app_id = azurerm_container_app.container_app_app.id
|
# container_app_id = azurerm_container_app.container_app_app.id
|
||||||
|
|
||||||
lifecycle {
|
# lifecycle {
|
||||||
ignore_changes = [ certificate_binding_type, container_app_environment_certificate_id ]
|
# ignore_changes = [ certificate_binding_type, container_app_environment_certificate_id ]
|
||||||
}
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
|
module "container_app" {
|
||||||
|
source = "github.com/noahspannbauer/noahspan-terraform/modules/container_app"
|
||||||
|
app_subdomain_name = var.APP_SUBDOMAIN_NAME
|
||||||
|
client_id = var.CLIENT_ID
|
||||||
|
client_secret = var.CLIENT_SECRET
|
||||||
|
container_app_app_name = module.environment.container_app_app_name
|
||||||
|
container_app_app_container_image = module.environment.container_app_api_container_image
|
||||||
|
container_app_app_container_name = module.environment.container_app_api_container_name
|
||||||
|
container_app_api_name = module.environment.container_app_api_name
|
||||||
|
container_app_api_container_image = module.environment.container_app_api_container_image
|
||||||
|
container_app_api_container_name = module.environment.container_app_api_container_name
|
||||||
|
container_app_environment_name = module.environment.container_app_environment_name
|
||||||
|
custom_domain_count = module.environment.custom_domain_count
|
||||||
|
dns_zone_resource_group = var.DNS_ZONE_RESOURCE_GROUP
|
||||||
|
docker_io_password = var.DOCKER_IO_PASSWORD
|
||||||
|
docker_io_username = var.DOCKER_IO_USERNAME
|
||||||
|
domain_name = var.DOMAIN_NAME
|
||||||
|
log_analytics_workspace_name = module.environment.log_analytics_workspace_name
|
||||||
|
resource_group_name = var.RESOURCE_GROUP_NAME
|
||||||
|
storage_account_name = module.environment.storage_account_name
|
||||||
|
storage_tables = module.environment.storage_tables
|
||||||
|
tenant_id = var.TENANT_ID
|
||||||
}
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
data "azurerm_resource_group" "resource_group" {
|
|
||||||
name = var.RESOURCE_GROUP_NAME
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
resource "azurerm_storage_account" "storage_account" {
|
|
||||||
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"
|
|
||||||
account_replication_type = "LRS"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_storage_table" "logs_table" {
|
|
||||||
name = "logs"
|
|
||||||
storage_account_name = azurerm_storage_account.storage_account.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_storage_table" "pilot_table" {
|
|
||||||
name = "pilots"
|
|
||||||
storage_account_name = azurerm_storage_account.storage_account.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_storage_table" "feature_flags_table" {
|
|
||||||
name = "featureFlags"
|
|
||||||
storage_account_name = azurerm_storage_account.storage_account.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_storage_table_entity" "logbook_feature_flag_entity" {
|
|
||||||
storage_table_id = azurerm_storage_table.feature_flags_table.id
|
|
||||||
|
|
||||||
partition_key = "featureFlag"
|
|
||||||
row_key = "logbook"
|
|
||||||
|
|
||||||
entity = {
|
|
||||||
active = module.environment.logbook_feature_flag_active
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_storage_table_entity" "pilots_feature_flag_entity" {
|
|
||||||
storage_table_id = azurerm_storage_table.feature_flags_table.id
|
|
||||||
|
|
||||||
partition_key = "featureFlag"
|
|
||||||
row_key = "pilots"
|
|
||||||
|
|
||||||
entity = {
|
|
||||||
active = module.environment.pilots_feature_flag_active
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,10 @@ variable "CLIENT_SECRET" {
|
|||||||
sensitive = true
|
sensitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "DNS_ZONE_RESOURCE_GROUP" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
variable "DOCKER_IO_PASSWORD" {
|
variable "DOCKER_IO_PASSWORD" {
|
||||||
type = string
|
type = string
|
||||||
sensitive = true
|
sensitive = true
|
||||||
@@ -28,10 +32,6 @@ variable "DOMAIN_NAME" {
|
|||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "REGION" {
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "RESOURCE_GROUP_NAME" {
|
variable "RESOURCE_GROUP_NAME" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user