diff --git a/api/README.md b/api/README.md index e69de29..a7caafe 100644 --- a/api/README.md +++ b/api/README.md @@ -0,0 +1,3 @@ +# Flying API + +An API for the Flying app. \ No newline at end of file diff --git a/app/README.md b/app/README.md index e69de29..69ebab8 100644 --- a/app/README.md +++ b/app/README.md @@ -0,0 +1,3 @@ +# Flying + +A pilot's logbook for tracking flight hours. \ No newline at end of file diff --git a/infrastructure/config/main.tf b/infrastructure/config/main.tf index 2ef1b08..9ad854a 100644 --- a/infrastructure/config/main.tf +++ b/infrastructure/config/main.tf @@ -5,8 +5,8 @@ locals { } container_app_app_container_image = { - test = "noahspan/flying-app:v0.0.1" - prod = "noahspan/flying-app:v0.0.1" + test = "noahspan/flying-app:v1.0.0" + prod = "noahspan/flying-app:v1.0.0" } container_app_app_container_name = { @@ -20,8 +20,8 @@ locals { } container_app_api_container_image = { - test = "noahspan/flying-api:v0.0.1" - prod = "noahspan/flying-api:v0.0.1" + test = "noahspan/flying-api:v1.0.0" + prod = "noahspan/flying-api:v1.0.0" } container_app_api_container_name = { @@ -29,11 +29,6 @@ locals { prod = "flying-api-prod" } - container_app_api_dapr_app_id = { - test = "flyingapitest" - prod = "flyingpapiprod" - } - container_app_environment_name = { test = "flying-test" prod = "flying-prod" @@ -63,4 +58,9 @@ locals { test = "noahspanflyingtest" prod = "noahspanflyingprod" } + + storage_tables = { + test = ["logs", "pilots"] + prod = ["logs", "pilots"] + } } \ No newline at end of file diff --git a/infrastructure/config/outputs.tf b/infrastructure/config/outputs.tf index b5384ed..bda1b15 100644 --- a/infrastructure/config/outputs.tf +++ b/infrastructure/config/outputs.tf @@ -22,10 +22,6 @@ output "container_app_api_container_name" { 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" { value = local.container_app_environment_name[var.environment] } @@ -48,4 +44,8 @@ output "pilots_feature_flag_active" { output "storage_account_name" { value = local.storage_account_name[var.environment] +} + +output "storage_tables" { + value = local.storage_tables[var.environment] } \ No newline at end of file diff --git a/infrastructure/dns.tf b/infrastructure/dns.tf deleted file mode 100644 index 346fa4e..0000000 --- a/infrastructure/dns.tf +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/infrastructure/main.tf b/infrastructure/main.tf index 77a2c02..30695c7 100644 --- a/infrastructure/main.tf +++ b/infrastructure/main.tf @@ -1,159 +1,183 @@ -data "azurerm_client_config" "current" { -} +# data "azurerm_client_config" "current" { +# } -resource "azurerm_log_analytics_workspace" "log_analytics_workspace" { - name = module.environment.log_analytics_workspace_name - location = data.azurerm_resource_group.resource_group.location - resource_group_name = data.azurerm_resource_group.resource_group.name - sku = "PerGB2018" - retention_in_days = 30 -} +# resource "azurerm_log_analytics_workspace" "log_analytics_workspace" { +# name = module.environment.log_analytics_workspace_name +# location = data.azurerm_resource_group.resource_group.location +# resource_group_name = data.azurerm_resource_group.resource_group.name +# sku = "PerGB2018" +# retention_in_days = 30 +# } -resource "azurerm_container_app_environment" "container_app_environment" { - name = module.environment.container_app_environment_name - location = data.azurerm_resource_group.resource_group.location - resource_group_name = data.azurerm_resource_group.resource_group.name - log_analytics_workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id -} +# resource "azurerm_container_app_environment" "container_app_environment" { +# name = module.environment.container_app_environment_name +# location = data.azurerm_resource_group.resource_group.location +# resource_group_name = data.azurerm_resource_group.resource_group.name +# log_analytics_workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id +# } -resource "azurerm_container_app" "container_app_api" { - name = module.environment.container_app_api_name - container_app_environment_id = azurerm_container_app_environment.container_app_environment.id - resource_group_name = data.azurerm_resource_group.resource_group.name - revision_mode = "Single" +# resource "azurerm_container_app" "container_app_api" { +# name = module.environment.container_app_api_name +# container_app_environment_id = azurerm_container_app_environment.container_app_environment.id +# resource_group_name = data.azurerm_resource_group.resource_group.name +# revision_mode = "Single" - registry { - server = "index.docker.io" - username = var.DOCKER_IO_USERNAME - password_secret_name = "docker-io-password" - } +# registry { +# server = "index.docker.io" +# username = var.DOCKER_IO_USERNAME +# password_secret_name = "docker-io-password" +# } - template { - min_replicas = 0 - max_replicas = 2 +# template { +# min_replicas = 0 +# max_replicas = 2 - container { - name = module.environment.container_app_api_container_name - image = module.environment.container_app_api_container_image - cpu = 0.25 - memory = "0.5Gi" +# container { +# name = module.environment.container_app_api_container_name +# image = module.environment.container_app_api_container_image +# cpu = 0.25 +# memory = "0.5Gi" - env { - name = "AZURE_STORAGE_CONNECTION_STRING" - secret_name = "azure-storage-connection-string" - } +# env { +# name = "AZURE_STORAGE_CONNECTION_STRING" +# secret_name = "azure-storage-connection-string" +# } - env { - name = "CLIENT_ID" - secret_name = "client-id" - } +# env { +# name = "CLIENT_ID" +# secret_name = "client-id" +# } - env { - name = "CLIENT_SECRET" - secret_name = "client-secret" - } +# env { +# name = "CLIENT_SECRET" +# secret_name = "client-secret" +# } - env { - name = "TENANT_ID" - secret_name = "tenant-id" - } - } - } +# env { +# name = "TENANT_ID" +# secret_name = "tenant-id" +# } +# } +# } - ingress { - allow_insecure_connections = false - external_enabled = true - target_port = 3000 - transport = "auto" +# ingress { +# allow_insecure_connections = false +# external_enabled = true +# target_port = 3000 +# transport = "auto" - traffic_weight { - latest_revision = true - percentage = 100 - } - } +# traffic_weight { +# latest_revision = true +# percentage = 100 +# } +# } - secret { - name = "docker-io-password" - value = var.DOCKER_IO_PASSWORD - } +# secret { +# name = "docker-io-password" +# value = var.DOCKER_IO_PASSWORD +# } - secret { - name = "azure-storage-connection-string" - value = azurerm_storage_account.storage_account.primary_connection_string - } +# secret { +# name = "azure-storage-connection-string" +# value = azurerm_storage_account.storage_account.primary_connection_string +# } - secret { - name = "client-id" - value = var.CLIENT_ID - } +# secret { +# name = "client-id" +# value = var.CLIENT_ID +# } - secret { - name = "client-secret" - value = var.CLIENT_SECRET - } +# secret { +# name = "client-secret" +# value = var.CLIENT_SECRET +# } - secret { - name = "tenant-id" - value = var.TENANT_ID - } +# secret { +# name = "tenant-id" +# value = var.TENANT_ID +# } - lifecycle { - ignore_changes = [ template[0].container[0].image ] - } -} +# lifecycle { +# ignore_changes = [ template[0].container[0].image ] +# } +# } -resource "azurerm_container_app" "container_app_app" { - name = module.environment.container_app_app_name - container_app_environment_id = azurerm_container_app_environment.container_app_environment.id - resource_group_name = data.azurerm_resource_group.resource_group.name - revision_mode = "Single" +# resource "azurerm_container_app" "container_app_app" { +# name = module.environment.container_app_app_name +# container_app_environment_id = azurerm_container_app_environment.container_app_environment.id +# resource_group_name = data.azurerm_resource_group.resource_group.name +# revision_mode = "Single" - registry { - server = "index.docker.io" - username = var.DOCKER_IO_USERNAME - password_secret_name = "docker-io-password" - } +# registry { +# server = "index.docker.io" +# username = var.DOCKER_IO_USERNAME +# password_secret_name = "docker-io-password" +# } - template { - min_replicas = 0 - max_replicas = 2 +# template { +# min_replicas = 0 +# max_replicas = 2 - container { - name = module.environment.container_app_app_container_name - image = module.environment.container_app_app_container_image - cpu = 0.25 - memory = "0.5Gi" - } - } +# container { +# name = module.environment.container_app_app_container_name +# image = module.environment.container_app_app_container_image +# cpu = 0.25 +# memory = "0.5Gi" +# } +# } - ingress { - allow_insecure_connections = false - external_enabled = true - target_port = 8080 - transport = "auto" +# ingress { +# allow_insecure_connections = false +# external_enabled = true +# target_port = 8080 +# transport = "auto" - traffic_weight { - latest_revision = true - percentage = 100 - } - } +# traffic_weight { +# latest_revision = true +# percentage = 100 +# } +# } - secret { - name = "docker-io-password" - value = var.DOCKER_IO_PASSWORD - } +# secret { +# name = "docker-io-password" +# value = var.DOCKER_IO_PASSWORD +# } - lifecycle { - ignore_changes = [ template[0].container[0].image ] - } -} +# lifecycle { +# ignore_changes = [ template[0].container[0].image ] +# } +# } -resource "azurerm_container_app_custom_domain" "custom_domain" { - count = module.environment.custom_domain_count - name = trimsuffix(trimprefix(azurerm_dns_txt_record.dns_txt_record[0].fqdn, "asuid."), ".") - container_app_id = azurerm_container_app.container_app_app.id +# resource "azurerm_container_app_custom_domain" "custom_domain" { +# count = module.environment.custom_domain_count +# name = trimsuffix(trimprefix(azurerm_dns_txt_record.dns_txt_record[0].fqdn, "asuid."), ".") +# container_app_id = azurerm_container_app.container_app_app.id - lifecycle { - ignore_changes = [ certificate_binding_type, container_app_environment_certificate_id ] - } +# lifecycle { +# 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 } \ No newline at end of file diff --git a/infrastructure/resource_group.tf b/infrastructure/resource_group.tf deleted file mode 100644 index cbaf81a..0000000 --- a/infrastructure/resource_group.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "azurerm_resource_group" "resource_group" { - name = var.RESOURCE_GROUP_NAME -} \ No newline at end of file diff --git a/infrastructure/storage_account.tf b/infrastructure/storage_account.tf deleted file mode 100644 index e55c1aa..0000000 --- a/infrastructure/storage_account.tf +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index 76a21dd..8c1a992 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -15,6 +15,10 @@ variable "CLIENT_SECRET" { sensitive = true } +variable "DNS_ZONE_RESOURCE_GROUP" { + type = string +} + variable "DOCKER_IO_PASSWORD" { type = string sensitive = true @@ -28,10 +32,6 @@ variable "DOMAIN_NAME" { type = string } -variable "REGION" { - type = string -} - variable "RESOURCE_GROUP_NAME" { type = string }