updating modules
This commit is contained in:
71
modules/container_app/container_app.tf
Normal file
71
modules/container_app/container_app.tf
Normal file
@@ -0,0 +1,71 @@
|
||||
resource "azurerm_container_app" "container_app_app" {
|
||||
name = var.container_app_name
|
||||
container_app_environment_id = var.container_app_environment_id
|
||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||
revision_mode = "Single"
|
||||
|
||||
registry {
|
||||
server = var.registry_server_name
|
||||
username = var.registry_username
|
||||
password_secret_name = var.registry_password_secret_name
|
||||
}
|
||||
|
||||
template {
|
||||
min_replicas = var.template_min_replicas
|
||||
max_replicas = var.template_max_replicas
|
||||
|
||||
dynamic "init_container" {
|
||||
for_each = var.init_containers
|
||||
content {
|
||||
name = init_container.value["name"]
|
||||
image = container.value["image"]
|
||||
cpu = init_container.value["cpu"]
|
||||
memory = init_container.value["memory"]
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "container" {
|
||||
for_each = var.containers
|
||||
content {
|
||||
name = container.value["name"]
|
||||
image = container.value["image"]
|
||||
cpu = container.value["cpu"]
|
||||
memory = container.value["memory"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ingress {
|
||||
allow_insecure_connections = var.ingress_allow_insecure_connections
|
||||
external_enabled = var.ingress_external_enabled
|
||||
target_port = var.ingress_target_port
|
||||
transport = var.ingress_transport
|
||||
|
||||
traffic_weight {
|
||||
latest_revision = true
|
||||
percentage = var.traffic_weight_percentage
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "secret" {
|
||||
for_each = var.secrets
|
||||
content {
|
||||
name = secret.value["name"]
|
||||
value = secret.value["value"]
|
||||
}
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [ template[0].container[0].image ]
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_container_app_custom_domain" "custom_domain" {
|
||||
count = var.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 ]
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
resource "azurerm_container_app" "container_app_api" {
|
||||
name = var.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"
|
||||
}
|
||||
|
||||
template {
|
||||
min_replicas = 0
|
||||
max_replicas = 2
|
||||
|
||||
container {
|
||||
name = var.container_app_api_container_name
|
||||
image = var.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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ingress {
|
||||
allow_insecure_connections = false
|
||||
external_enabled = true
|
||||
target_port = 3000
|
||||
transport = "auto"
|
||||
|
||||
traffic_weight {
|
||||
latest_revision = true
|
||||
percentage = 100
|
||||
}
|
||||
}
|
||||
|
||||
secret {
|
||||
name = "docker-io-password"
|
||||
value = var.docker_io_password
|
||||
}
|
||||
|
||||
secret {
|
||||
name = "azure-storage-connection-string"
|
||||
value = var.storage_account_primary_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 ]
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
resource "azurerm_container_app" "container_app_app" {
|
||||
name = var.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"
|
||||
}
|
||||
|
||||
template {
|
||||
min_replicas = 0
|
||||
max_replicas = 2
|
||||
|
||||
container {
|
||||
name = var.container_app_app_container_name
|
||||
image = var.container_app_app_container_image
|
||||
cpu = 0.25
|
||||
memory = "0.5Gi"
|
||||
}
|
||||
}
|
||||
|
||||
ingress {
|
||||
allow_insecure_connections = false
|
||||
external_enabled = true
|
||||
target_port = 8080
|
||||
transport = "auto"
|
||||
|
||||
traffic_weight {
|
||||
latest_revision = true
|
||||
percentage = 100
|
||||
}
|
||||
}
|
||||
|
||||
secret {
|
||||
name = "docker-io-password"
|
||||
value = var.docker_io_password
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [ template[0].container[0].image ]
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_container_app_custom_domain" "custom_domain" {
|
||||
count = var.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 ]
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
resource "azurerm_log_analytics_workspace" "log_analytics_workspace" {
|
||||
name = var.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 = var.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
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
data "azurerm_dns_zone" "dns_zone" {
|
||||
name = var.domain_name
|
||||
}
|
||||
|
||||
data "azurerm_resource_group" "dns_zone_resource_group" {
|
||||
name = var.dns_zone_resource_group
|
||||
}
|
||||
|
||||
resource "azurerm_dns_txt_record" "dns_txt_record" {
|
||||
count = var.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
|
||||
}
|
||||
}
|
||||
@@ -2,40 +2,21 @@ variable "app_subdomain_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "client_id" {
|
||||
variable "containers" {
|
||||
type = list(object({
|
||||
name = string
|
||||
image = string
|
||||
cpu = string
|
||||
memory = string
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "container_app_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "client_secret" {
|
||||
sensitive = true
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "container_app_app_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "container_app_app_container_image" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "container_app_app_container_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "container_app_api_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "container_app_api_container_image" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "container_app_api_container_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "container_app_environment_name" {
|
||||
variable "container_app_environment_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -43,12 +24,22 @@ variable "custom_domain_count" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "docker_io_password" {
|
||||
variable "init_containers" {
|
||||
default = []
|
||||
type = list(object({
|
||||
name = string
|
||||
image = string
|
||||
cpu = string
|
||||
memory = string
|
||||
}))
|
||||
}
|
||||
|
||||
variable "registry_password" {
|
||||
sensitive = true
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "docker_io_username" {
|
||||
variable "registry_username" {
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -60,7 +51,32 @@ variable "dns_zone_resource_group" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "log_analytics_workspace_name" {
|
||||
variable "ingress_external_enabled" {
|
||||
default = false
|
||||
type = bool
|
||||
}
|
||||
|
||||
variable "ingress_allow_insecure_connections" {
|
||||
default = false
|
||||
type = bool
|
||||
}
|
||||
|
||||
variable "ingress_target_port" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "ingress_transport" {
|
||||
default = "auto"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "registry_password_secret_name" {
|
||||
default = "docker-io-password"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "registry_server_name" {
|
||||
default = "index.docker.io"
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -68,10 +84,29 @@ variable "resource_group_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "secrets" {
|
||||
default = []
|
||||
type = list(object({
|
||||
name = string
|
||||
value = string
|
||||
}))
|
||||
}
|
||||
|
||||
variable "storage_account_primary_connection_string" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tenant_id" {
|
||||
type = string
|
||||
variable "traffic_weight_percentage" {
|
||||
default = 100
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "template_min_replicas" {
|
||||
default = 0
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "template_max_replicas" {
|
||||
default = 1
|
||||
type = number
|
||||
}
|
||||
Reference in New Issue
Block a user