Skip to content

Instantly share code, notes, and snippets.

@magodo
Created January 21, 2022 07:17
Show Gist options
  • Save magodo/5dca2240571faa2e232dc8b609e12c56 to your computer and use it in GitHub Desktop.
Save magodo/5dca2240571faa2e232dc8b609e12c56 to your computer and use it in GitHub Desktop.
container group
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-220121144644318289"
location = "West Europe"
}
resource "azurerm_storage_account" "test" {
name = "accsa220121144644318289"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_storage_share" "test" {
name = "acctestss-220121144644318289"
storage_account_name = azurerm_storage_account.test.name
quota = 50
}
resource "azurerm_virtual_network" "test" {
name = "testvnet"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.1.0.0/16"]
}
resource "azurerm_subnet" "test" {
name = "testsubnet"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "10.1.0.0/24"
delegation {
name = "delegation"
service_delegation {
name = "Microsoft.ContainerInstance/containerGroups"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
}
}
resource "azurerm_network_profile" "test" {
name = "testnetprofile"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
container_network_interface {
name = "testcnic"
ip_configuration {
name = "testipconfig"
subnet_id = azurerm_subnet.test.id
}
}
}
resource "azurerm_container_group" "test" {
count = 4
name = "worker${count.index}"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
ip_address_type = "private"
os_type = "Linux"
network_profile_id = azurerm_network_profile.test.id
container {
name = "hf"
image = "seanmckenna/aci-hellofiles"
cpu = "1"
memory = "1.5"
ports {
port = 80
protocol = "TCP"
}
volume {
name = "logs"
mount_path = "/aci/logs"
read_only = false
share_name = azurerm_storage_share.test.name
storage_account_name = azurerm_storage_account.test.name
storage_account_key = azurerm_storage_account.test.primary_access_key
}
commands = ["/bin/bash", "-c", "ls"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment