github.com/swisspost/terratest@v0.0.0-20230214120104-7ec6de2e1ae0/examples/azure/terraform-azure-aci-example/main.tf (about)

     1  # ---------------------------------------------------------------------------------------------------------------------
     2  # DEPLOY AN AZURE CONTAINER Instance
     3  # This is an example of how to deploy an Azure Container Instance
     4  # See test/terraform_azure_aci_example_test.go for how to write automated tests for this code.
     5  # ---------------------------------------------------------------------------------------------------------------------
     6  
     7  # ------------------------------------------------------------------------------
     8  # CONFIGURE OUR AZURE CONNECTION
     9  # ------------------------------------------------------------------------------
    10  
    11  provider "azurerm" {
    12    version = "~>2.29.0"
    13    features {}
    14  }
    15  
    16  # ---------------------------------------------------------------------------------------------------------------------
    17  # DEPLOY A RESOURCE GROUP
    18  # ---------------------------------------------------------------------------------------------------------------------
    19  
    20  resource "azurerm_resource_group" "rg" {
    21    name     = "terratest-aci-rg-${var.postfix}"
    22    location = var.location
    23  }
    24  
    25  # ---------------------------------------------------------------------------------------------------------------------
    26  # DEPLOY AN AZURE CONTAINER INSTANCE
    27  # ---------------------------------------------------------------------------------------------------------------------
    28  
    29  resource "azurerm_container_group" "aci" {
    30    name                = "aci${var.postfix}"
    31    location            = azurerm_resource_group.rg.location
    32    resource_group_name = azurerm_resource_group.rg.name
    33  
    34    ip_address_type = "public"
    35    dns_name_label  = "aci${var.postfix}"
    36    os_type         = "Linux"
    37  
    38    container {
    39      name   = "hello-world"
    40      image  = "mcr.microsoft.com/azuredocs/aci-helloworld:latest"
    41      cpu    = "0.5"
    42      memory = "1.5"
    43  
    44      ports {
    45        port     = 443
    46        protocol = "TCP"
    47      }
    48    }
    49  
    50    tags = {
    51      Environment = "Development"
    52    }
    53  }