Initial put
This commit is contained in:
		
							
								
								
									
										23
									
								
								quickstart/101-container-instance-subnet/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								quickstart/101-container-instance-subnet/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					# Azure Container Instance
 | 
				
			||||||
 | 
					This template deploys an Azure Container Instance.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Terraform resource types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
 | 
				
			||||||
 | 
					- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
 | 
				
			||||||
 | 
					- [azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network)
 | 
				
			||||||
 | 
					- [azurerm_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet)
 | 
				
			||||||
 | 
					- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
 | 
				
			||||||
 | 
					- [azurerm_container_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_group)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					| Name | Description | Default value |
 | 
				
			||||||
 | 
					|-|-|-|
 | 
				
			||||||
 | 
					| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
 | 
				
			||||||
 | 
					| `resource_group_location` | Location of the resource group. | eastus |
 | 
				
			||||||
 | 
					| `virtual_network_name` | Name of the virtual network resource. | "" |
 | 
				
			||||||
 | 
					| `subnet_name` | Name of the virtual network subnet. | "" |
 | 
				
			||||||
 | 
					| `container_group_name` | Name of the container group resource. | "" |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Example
 | 
				
			||||||
							
								
								
									
										89
									
								
								quickstart/101-container-instance-subnet/main.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								quickstart/101-container-instance-subnet/main.tf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
				
			|||||||
 | 
					resource "random_pet" "rg_name" {
 | 
				
			||||||
 | 
					  prefix = var.resource_group_name_prefix
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "azurerm_resource_group" "rg" {
 | 
				
			||||||
 | 
					  location = var.resource_group_location
 | 
				
			||||||
 | 
					  name     = random_pet.rg_name.id
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "random_string" "azurerm_virtual_network_name" {
 | 
				
			||||||
 | 
					  length  = 13
 | 
				
			||||||
 | 
					  lower   = true
 | 
				
			||||||
 | 
					  numeric = false
 | 
				
			||||||
 | 
					  special = false
 | 
				
			||||||
 | 
					  upper   = false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "azurerm_virtual_network" "example" {
 | 
				
			||||||
 | 
					  name                = coalesce(var.virtual_network_name, "vnet-${random_string.azurerm_virtual_network_name.result}")
 | 
				
			||||||
 | 
					  resource_group_name = azurerm_resource_group.rg.name
 | 
				
			||||||
 | 
					  address_space       = ["10.0.0.0/16"] 
 | 
				
			||||||
 | 
					  location            = azurerm_resource_group.rg.location 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "random_string" "azurerm_subnet_name" {
 | 
				
			||||||
 | 
					  length  = 13
 | 
				
			||||||
 | 
					  lower   = true
 | 
				
			||||||
 | 
					  numeric = false
 | 
				
			||||||
 | 
					  special = false
 | 
				
			||||||
 | 
					  upper   = false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "azurerm_subnet" "example" {
 | 
				
			||||||
 | 
					  name                 = coalesce(var.subnet_name, "subnet-${random_string.azurerm_subnet_name.result}")
 | 
				
			||||||
 | 
					  resource_group_name  = azurerm_resource_group.rg.name
 | 
				
			||||||
 | 
					  virtual_network_name = azurerm_virtual_network.example.name
 | 
				
			||||||
 | 
					  address_prefixes     = ["10.0.2.0/24"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  delegation {
 | 
				
			||||||
 | 
					    name = "delegation"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    service_delegation {
 | 
				
			||||||
 | 
					      name    = "Microsoft.ContainerInstance/containerGroups"
 | 
				
			||||||
 | 
					      actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "random_string" "azurerm_container_group_name" {
 | 
				
			||||||
 | 
					  length  = 13
 | 
				
			||||||
 | 
					  lower   = true
 | 
				
			||||||
 | 
					  numeric = false
 | 
				
			||||||
 | 
					  special = false
 | 
				
			||||||
 | 
					  upper   = false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "azurerm_container_group" "example" {
 | 
				
			||||||
 | 
					  name                = coalesce(var.container_group_name, "cg-${random_string.azurerm_container_group_name.result}")
 | 
				
			||||||
 | 
					  resource_group_name = azurerm_resource_group.rg.name
 | 
				
			||||||
 | 
					  location            = azurerm_resource_group.rg.location
 | 
				
			||||||
 | 
					  ip_address_type     = "Private"
 | 
				
			||||||
 | 
					  os_type             = "Linux"
 | 
				
			||||||
 | 
					  restart_policy      = "Never"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  container {
 | 
				
			||||||
 | 
					    name   = "hello-world"
 | 
				
			||||||
 | 
					    image  = "mcr.microsoft.com/azuredocs/aci-helloworld:latest"
 | 
				
			||||||
 | 
					    cpu    = "0.5"
 | 
				
			||||||
 | 
					    memory = "1.5"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ports {
 | 
				
			||||||
 | 
					      port     = 443
 | 
				
			||||||
 | 
					      protocol = "TCP"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  container {
 | 
				
			||||||
 | 
					    name   = "sidecar"
 | 
				
			||||||
 | 
					    image  = "mcr.microsoft.com/azuredocs/aci-tutorial-sidecar"
 | 
				
			||||||
 | 
					    cpu    = "0.5"
 | 
				
			||||||
 | 
					    memory = "1.5"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  subnet_ids = [azurerm_subnet.example.id]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  tags = {
 | 
				
			||||||
 | 
					    environment = "testing"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										15
									
								
								quickstart/101-container-instance-subnet/outputs.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								quickstart/101-container-instance-subnet/outputs.tf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					output "resource_group_name" {
 | 
				
			||||||
 | 
					  value = azurerm_resource_group.rg.name
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					output "virtual_network_name" {
 | 
				
			||||||
 | 
					  value = azurerm_virtual_network.example.name
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					output "subnet_name" {
 | 
				
			||||||
 | 
					  value = azurerm_subnet.example.name
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					output "container_group_name" {
 | 
				
			||||||
 | 
					  value = azurerm_container_group.example.name
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										18
									
								
								quickstart/101-container-instance-subnet/providers.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								quickstart/101-container-instance-subnet/providers.tf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					terraform {
 | 
				
			||||||
 | 
					  required_version = ">=1.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  required_providers {
 | 
				
			||||||
 | 
					    azurerm = {
 | 
				
			||||||
 | 
					      source  = "hashicorp/azurerm"
 | 
				
			||||||
 | 
					      version = "~>3.0"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    random = {
 | 
				
			||||||
 | 
					      source  = "hashicorp/random"
 | 
				
			||||||
 | 
					      version = "~>3.0"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					provider "azurerm" {
 | 
				
			||||||
 | 
					  features {}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										29
									
								
								quickstart/101-container-instance-subnet/variables.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								quickstart/101-container-instance-subnet/variables.tf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					variable "resource_group_name_prefix" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  default     = "rg"
 | 
				
			||||||
 | 
					  description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "resource_group_location" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  default     = "eastus"
 | 
				
			||||||
 | 
					  description = "Location of the resource group."
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "virtual_network_name" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "The name of the virtual network resource. The value will be randomly generated if blank."
 | 
				
			||||||
 | 
					  default     = ""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "subnet_name" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "The name of the virtual network subnet. The value will be randomly generated if blank."
 | 
				
			||||||
 | 
					  default     = ""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "container_group_name" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "The name of the container group resource. The value will be randomly generated if blank."
 | 
				
			||||||
 | 
					  default     = ""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user