first commit
This commit is contained in:
2
modules/container_app/client_config.tf
Normal file
2
modules/container_app/client_config.tf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
data "azurerm_client_config" "current" {
|
||||||
|
}
|
||||||
85
modules/container_app/container_app_api.tf
Normal file
85
modules/container_app/container_app_api.tf
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
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 = azurerm_storage_account.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 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
55
modules/container_app/container_app_app.tf
Normal file
55
modules/container_app/container_app_app.tf
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
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 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
14
modules/container_app/container_app_environment.tf
Normal file
14
modules/container_app/container_app_environment.tf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
19
modules/container_app/dns.tf
Normal file
19
modules/container_app/dns.tf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
3
modules/container_app/resource_group.tf
Normal file
3
modules/container_app/resource_group.tf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
data "azurerm_resource_group" "resource_group" {
|
||||||
|
name = var.resource_group_name
|
||||||
|
}
|
||||||
13
modules/container_app/storage_account.tf
Normal file
13
modules/container_app/storage_account.tf
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
resource "azurerm_storage_account" "storage_account" {
|
||||||
|
name = var.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" "storage_table" {
|
||||||
|
count = length(var.storage_tables)
|
||||||
|
name = var.storage_tables[count.index]
|
||||||
|
storage_account_name = azurerm_storage_account.storage_account.name
|
||||||
|
}
|
||||||
81
modules/container_app/variables.tf
Normal file
81
modules/container_app/variables.tf
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
variable "app_subdomain_name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "client_id" {
|
||||||
|
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" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "custom_domain_count" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "docker_io_password" {
|
||||||
|
sensitive = true
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "docker_io_username" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "domain_name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "dns_zone_resource_group" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "log_analytics_workspace_name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "resource_group_name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "storage_account_name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "storage_tables" {
|
||||||
|
type = list(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "tenant_id" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user