Refactoring
This commit is contained in:
@@ -3,7 +3,6 @@ locals {
|
||||
dev = "flying-app-dev"
|
||||
}
|
||||
|
||||
|
||||
container_app_app_container_image = {
|
||||
dev = "noahspan/flying-app:v0.0.1"
|
||||
}
|
||||
@@ -32,6 +31,10 @@ locals {
|
||||
dev = "flying-dev"
|
||||
}
|
||||
|
||||
logbook_feature_flag_active = {
|
||||
dev = "true"
|
||||
}
|
||||
|
||||
key_vault_name = {
|
||||
dev = "noahspanflyingkeyvault"
|
||||
}
|
||||
@@ -40,11 +43,11 @@ locals {
|
||||
dev = "flying-log-analytics-workspace-dev"
|
||||
}
|
||||
|
||||
pilots_feature_flag_active = {
|
||||
dev = "true"
|
||||
}
|
||||
|
||||
storage_account_name = {
|
||||
dev = "noahspanflyingdev"
|
||||
}
|
||||
|
||||
user_assigned_identity_name = {
|
||||
dev = "noahspanflyingdevuser"
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,18 @@ output "key_vault_name" {
|
||||
value = local.key_vault_name[var.environment]
|
||||
}
|
||||
|
||||
output "logbook_feature_flag_active" {
|
||||
value = local.logbook_feature_flag_active[var.environment]
|
||||
}
|
||||
|
||||
output "log_analytics_workspace_name" {
|
||||
value = local.log_analytics_workspace_name[var.environment]
|
||||
}
|
||||
|
||||
output "storage_account_name" {
|
||||
value = local.storage_account_name[var.environment]
|
||||
output "pilots_feature_flag_active" {
|
||||
value = local.pilots_feature_flag_active[var.environment]
|
||||
}
|
||||
|
||||
output "user_assigned_identity_name" {
|
||||
value = local.user_assigned_identity_name[var.environment]
|
||||
output "storage_account_name" {
|
||||
value = local.storage_account_name[var.environment]
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
resource "azurerm_container_app_environment_dapr_component" "table_storage_pilots_dapr_component" {
|
||||
name = "table-storage-pilots"
|
||||
container_app_environment_id = azurerm_container_app_environment.container_app_environment.id
|
||||
component_type = "state.azure.tablestorage"
|
||||
version = "v1"
|
||||
|
||||
metadata {
|
||||
name = "accountName"
|
||||
value = azurerm_storage_account.storage_account.name
|
||||
}
|
||||
|
||||
metadata {
|
||||
name = "azureClientId"
|
||||
value = azurerm_user_assigned_identity.user_assigned_identity.id
|
||||
}
|
||||
|
||||
metadata {
|
||||
name = "tableName"
|
||||
value = "Pilots"
|
||||
}
|
||||
|
||||
scopes = [ azurerm_container_app.container_app_api.dapr[0].app_id ]
|
||||
}
|
||||
|
||||
resource "azurerm_container_app_environment_dapr_component" "table_storage_logbook_dapr_component" {
|
||||
name = "table-storage-logbook"
|
||||
container_app_environment_id = azurerm_container_app_environment.container_app_environment.id
|
||||
component_type = "state.azure.tablestorage"
|
||||
version = "v1"
|
||||
|
||||
metadata {
|
||||
name = "accountName"
|
||||
value = azurerm_storage_account.storage_account.name
|
||||
}
|
||||
|
||||
metadata {
|
||||
name = "azureClientId"
|
||||
value = azurerm_user_assigned_identity.user_assigned_identity.client_id
|
||||
}
|
||||
|
||||
metadata {
|
||||
name = "tableName"
|
||||
value = "Logbook"
|
||||
}
|
||||
|
||||
scopes = [ azurerm_container_app.container_app_api.dapr[0].app_id ]
|
||||
}
|
||||
|
||||
resource "azurerm_container_app_environment_dapr_component" "key_vault_dapr_component" {
|
||||
name = "key-vault"
|
||||
container_app_environment_id = azurerm_container_app_environment.container_app_environment.id
|
||||
component_type = "secretstores.azure.keyvault"
|
||||
version = "v1"
|
||||
|
||||
metadata {
|
||||
name = "vaultName"
|
||||
value = azurerm_key_vault.key_vault.name
|
||||
}
|
||||
|
||||
metadata {
|
||||
name = "azureClientId"
|
||||
value = azurerm_user_assigned_identity.user_assigned_identity.client_id
|
||||
}
|
||||
|
||||
scopes = [ azurerm_container_app.container_app_api.dapr[0].app_id ]
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
resource "azurerm_user_assigned_identity" "user_assigned_identity" {
|
||||
name = module.environment.user_assigned_identity_name
|
||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||
location = data.azurerm_resource_group.resource_group.location
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
resource "azurerm_key_vault" "key_vault" {
|
||||
name = module.environment.key_vault_name
|
||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||
location = data.azurerm_resource_group.resource_group.location
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
soft_delete_retention_days = 7
|
||||
sku_name = "standard"
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault_access_policy" "key_vault_access_policy_cli" {
|
||||
key_vault_id = azurerm_key_vault.key_vault.id
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
object_id = data.azurerm_client_config.current.object_id
|
||||
|
||||
key_permissions = [
|
||||
"Create",
|
||||
"Get",
|
||||
]
|
||||
|
||||
secret_permissions = [
|
||||
"Set",
|
||||
"Get",
|
||||
"Delete",
|
||||
"Purge",
|
||||
"Recover"
|
||||
]
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault_access_policy" "key_vault_access_policy_user_assigned_identity" {
|
||||
key_vault_id = azurerm_key_vault.key_vault.id
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
object_id = azurerm_user_assigned_identity.user_assigned_identity.principal_id
|
||||
|
||||
key_permissions = [
|
||||
"Create",
|
||||
"Get",
|
||||
]
|
||||
|
||||
secret_permissions = [
|
||||
"Set",
|
||||
"Get",
|
||||
"Delete",
|
||||
"Purge",
|
||||
"Recover"
|
||||
]
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault_secret" "client_id_key_vault_secret" {
|
||||
name = "client-id"
|
||||
value = var.CLIENT_ID
|
||||
key_vault_id = azurerm_key_vault.key_vault.id
|
||||
|
||||
depends_on = [ azurerm_key_vault_access_policy.key_vault_access_policy_cli ]
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault_secret" "client_secret_key_vault_secret" {
|
||||
name = "client-secret"
|
||||
value = var.CLIENT_SECRET
|
||||
key_vault_id = azurerm_key_vault.key_vault.id
|
||||
|
||||
depends_on = [ azurerm_key_vault_access_policy.key_vault_access_policy_cli ]
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault_secret" "tenant_id_key_vault_secret" {
|
||||
name = "tenant-id"
|
||||
value = var.TENANT_ID
|
||||
key_vault_id = azurerm_key_vault.key_vault.id
|
||||
|
||||
depends_on = [ azurerm_key_vault_access_policy.key_vault_access_policy_cli ]
|
||||
}
|
||||
@@ -42,6 +42,26 @@ resource "azurerm_container_app" "container_app_api" {
|
||||
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 = "CLIENT_ID"
|
||||
secret_name = "client-id"
|
||||
}
|
||||
|
||||
env {
|
||||
name = "CLIENT_SECRET"
|
||||
secret_name = "client-secret"
|
||||
}
|
||||
|
||||
env {
|
||||
name = "TENANT_ID"
|
||||
secret_name = "tenant-id"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +82,26 @@ resource "azurerm_container_app" "container_app_api" {
|
||||
value = var.DOCKER_IO_PASSWORD
|
||||
}
|
||||
|
||||
secret {
|
||||
name = "azure-storage-connection-string"
|
||||
value = var.AZURE_STORAGE_CONNECTION_STRING
|
||||
}
|
||||
|
||||
secret {
|
||||
name = "client-id"
|
||||
value = var.CLIENT_ID
|
||||
}
|
||||
|
||||
secret {
|
||||
name = "client-secret"
|
||||
value = var.CLIENT_SECRET
|
||||
}
|
||||
|
||||
secret {
|
||||
name = "tenant-id"
|
||||
value = var.TENANT_ID
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [ template[0].container[0].image ]
|
||||
}
|
||||
|
||||
@@ -4,11 +4,6 @@ resource "azurerm_storage_account" "storage_account" {
|
||||
location = data.azurerm_resource_group.resource_group.location
|
||||
account_tier = "Standard"
|
||||
account_replication_type = "LRS"
|
||||
|
||||
identity {
|
||||
type = "UserAssigned"
|
||||
identity_ids = [azurerm_user_assigned_identity.user_assigned_identity.id]
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_storage_table" "logs_table" {
|
||||
@@ -19,4 +14,31 @@ resource "azurerm_storage_table" "logs_table" {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@ variable "APP_SUBDOMAIN_NAME" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "AZURE_STORAGE_CONNECTION_STRING" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "CLIENT_ID" {
|
||||
type = string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user