Last active
December 15, 2020 15:05
-
-
Save daloulou/8186d0b92c91a5c1c020eef702674b7e to your computer and use it in GitHub Desktop.
Terraform file to deploy you app with traefik sidecar on Azure Container Instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "azurerm" { | |
version = "=2.36.0" | |
features {} | |
} | |
data "azurerm_resource_group" "example" { | |
name = var.example_ressource_group_name | |
} | |
data "azurerm_storage_account" "example" { | |
name = var.example_storage_account_name | |
resource_group_name = data.azurerm_resource_group.example.name | |
} | |
resource "azurerm_container_group" "example-api" { | |
name = "example-api-container" | |
location = data.azurerm_resource_group.example.location | |
resource_group_name = data.azurerm_resource_group.example.name | |
ip_address_type = "public" | |
dns_name_label = var.example_api_dns | |
os_type = "Linux" | |
container { | |
name = "api" | |
image = var.api_image | |
cpu = var.azurerm_container_cpu | |
memory = var.azurerm_container_memory | |
} | |
container { | |
name = "traefik-sidecar" | |
image = "traefik:2.3" | |
cpu = var.azurerm_container_cpu | |
memory = var.azurerm_container_memory | |
commands = ["sh","-c","touch acme.json && chmod 600 acme.json && traefik"] | |
environment_variables = { | |
MY_APP_URL="${var.example_app_url}" | |
TRAEFIK_URL="${var.traefik_url}" | |
} | |
ports { | |
port = 80 | |
protocol = "TCP" | |
} | |
ports { | |
port = 443 | |
protocol = "TCP" | |
} | |
volume { | |
name = "traefik-config" | |
read_only = true | |
mount_path = "/etc/traefik/" | |
storage_account_name = data.azurerm_storage_account.example.name | |
share_name = "traefik" | |
storage_account_key = data.azurerm_storage_account.example.primary_access_key | |
} | |
} | |
} | |
output "app-fqdn" { | |
value = azurerm_container_group.example-api.fqdn | |
description = "The fqdn of the app instance." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment