Added Docker/Podman build information.
This commit is contained in:
91
main.tf
Normal file
91
main.tf
Normal file
@@ -0,0 +1,91 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = ">= 4.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
backend "local" {
|
||||
path = "azure-image-chooser.tfstate"
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
|
||||
subscription_id = var.subscription_id
|
||||
}
|
||||
|
||||
variable "subscription_id" {
|
||||
description = "The Azure Subscription ID to use for the resources."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "project_name" {
|
||||
description = "The name used to construct Azure resource names."
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
name = "rg-${var.project_name}"
|
||||
location = "Poland Central"
|
||||
}
|
||||
|
||||
resource "azurerm_log_analytics_workspace" "logaws" {
|
||||
name = "${var.project_name}-logs"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
sku = "PerGB2018"
|
||||
retention_in_days = 30
|
||||
}
|
||||
|
||||
resource "azurerm_container_app_environment" "env" {
|
||||
name = "${var.project_name}-env"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
log_analytics_workspace_id = azurerm_log_analytics_workspace.logaws.id
|
||||
|
||||
workload_profile {
|
||||
name = "Consumption"
|
||||
workload_profile_type = "Consumption"
|
||||
maximum_count = 1
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_container_app" "app" {
|
||||
name = "${var.project_name}-app"
|
||||
container_app_environment_id = azurerm_container_app_environment.env.id
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
revision_mode = "Single"
|
||||
|
||||
template {
|
||||
container {
|
||||
name = "${var.project_name}-container"
|
||||
image = "skdomlab.azurecr.io/azure-image-chooser:latest"
|
||||
cpu = "0.25"
|
||||
memory = "0.5Gi"
|
||||
}
|
||||
}
|
||||
identity {
|
||||
type = "UserAssigned"
|
||||
identity_ids = [azurerm_user_assigned_identity.uai.id]
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_user_assigned_identity" "uai" {
|
||||
name = "${var.project_name}-uai"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
}
|
||||
|
||||
resource "azurerm_role_assignment" "acr_pull" {
|
||||
scope = data.azurerm_container_registry.acr.id
|
||||
role_definition_name = "AcrPull"
|
||||
principal_id = azurerm_user_assigned_identity.uai.principal_id
|
||||
}
|
||||
|
||||
data "azurerm_container_registry" "acr" {
|
||||
name = "skdomlab"
|
||||
resource_group_name = "dom-lab-common"
|
||||
}
|
||||
Reference in New Issue
Block a user