-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55754aa
commit 3d91800
Showing
5 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
quickstart/101-container-instance-multiple-containers/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Azure Container Group | ||
|
||
This template deploys an Azure Container Group with two containers. | ||
|
||
## 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_container_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_group) | ||
|
||
## Variables | ||
|
||
| Name | Description | Default | | ||
|-|-|-| | ||
| `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 | | ||
|
||
## Example |
44 changes: 44 additions & 0 deletions
44
quickstart/101-container-instance-multiple-containers/main.tf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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_pet" "azurerm_container_group_name" { | ||
prefix = "cont" | ||
} | ||
|
||
resource "azurerm_container_group" "example" { | ||
name = "${random_pet.azurerm_container_group_name.id}-examplecont" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
ip_address_type = "Public" | ||
dns_name_label = "${random_pet.azurerm_container_group_name.id}-examplecont" | ||
os_type = "Linux" | ||
|
||
container { | ||
name = "hw" | ||
image = "mcr.microsoft.com/azuredocs/aci-helloworld:latest" | ||
cpu = "0.5" | ||
memory = "1.5" | ||
|
||
ports { | ||
port = 80 | ||
protocol = "TCP" | ||
} | ||
} | ||
|
||
container { | ||
name = "sidecar" | ||
image = "mcr.microsoft.com/azuredocs/aci-tutorial-sidecar" | ||
cpu = "0.5" | ||
memory = "1.5" | ||
} | ||
|
||
tags = { | ||
environment = "testing" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
quickstart/101-container-instance-multiple-containers/outputs.tf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
output "resource_group_name" { | ||
value = azurerm_resource_group.rg.name | ||
} | ||
|
||
output "container_group_name" { | ||
value = azurerm_container_group.example.name | ||
} | ||
|
||
output "ip_address" { | ||
value = azurerm_container_group.example.ip_address | ||
} | ||
|
||
output "fqdn" { | ||
value = azurerm_container_group.example.fqdn | ||
} |
16 changes: 16 additions & 0 deletions
16
quickstart/101-container-instance-multiple-containers/providers.tf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
terraform { | ||
required_version = ">=1.0" | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~>3.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = "~>3.0" | ||
} | ||
} | ||
} | ||
provider "azurerm" { | ||
features {} | ||
} |
11 changes: 11 additions & 0 deletions
11
quickstart/101-container-instance-multiple-containers/variables.tf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
variable "resource_group_location" { | ||
type = string | ||
default = "eastus" | ||
description = "Location of the resource group." | ||
} | ||
|
||
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." | ||
} |