Compare commits
1 Commits
UserStory3
...
UserStory3
Author | SHA1 | Date | |
---|---|---|---|
b0f6583de4 |
@ -1,44 +0,0 @@
|
|||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +1,19 @@
|
|||||||
# Azure Container Group
|
# Azure Container Instance with Azure File Share
|
||||||
|
|
||||||
This template deploys an Azure Container Group with two containers.
|
This template deploys an Azure Container Instance with an Azure File Share as a volume mount.
|
||||||
|
|
||||||
## Terraform resource types
|
## Terraform resource types
|
||||||
|
|
||||||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
- [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_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||||
|
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
|
||||||
|
- [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account)
|
||||||
|
- [azurerm_storage_share](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_share)
|
||||||
- [azurerm_container_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_group)
|
- [azurerm_container_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_group)
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
| Name | Description | Default |
|
| 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_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 |
|
| `resource_group_location` | Location of the resource group. | eastus |
|
81
quickstart/101-container-instance-volume-mount/main.tf
Normal file
81
quickstart/101-container-instance-volume-mount/main.tf
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
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" "storage_account_name" {
|
||||||
|
length = 8
|
||||||
|
lower = true
|
||||||
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_storage_account" "example" {
|
||||||
|
name = random_string.storage_account_name.result
|
||||||
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
|
location = azurerm_resource_group.rg.location
|
||||||
|
account_tier = "Standard"
|
||||||
|
account_replication_type = "LRS"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "random_string" "storage_share_name" {
|
||||||
|
length = 8
|
||||||
|
lower = true
|
||||||
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_storage_share" "example" {
|
||||||
|
name = random_string.storage_share_name.result
|
||||||
|
storage_account_name = azurerm_storage_account.example.name
|
||||||
|
quota = 50
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "random_string" "container_group_name" {
|
||||||
|
length = 8
|
||||||
|
lower = true
|
||||||
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_container_group" "example" {
|
||||||
|
name = random_string.container_group_name.result
|
||||||
|
location = azurerm_resource_group.rg.location
|
||||||
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
|
ip_address_type = "Public"
|
||||||
|
dns_name_label = random_string.container_group_name.result
|
||||||
|
os_type = "Linux"
|
||||||
|
|
||||||
|
container {
|
||||||
|
name = "webserver"
|
||||||
|
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.example.name
|
||||||
|
|
||||||
|
storage_account_name = azurerm_storage_account.example.name
|
||||||
|
storage_account_key = azurerm_storage_account.example.primary_access_key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tags = {
|
||||||
|
environment = "testing"
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,14 @@ output "resource_group_name" {
|
|||||||
value = azurerm_resource_group.rg.name
|
value = azurerm_resource_group.rg.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "storage_account_name" {
|
||||||
|
value = azurerm_storage_account.example.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "storage_share_name" {
|
||||||
|
value = azurerm_storage_share.example.name
|
||||||
|
}
|
||||||
|
|
||||||
output "container_group_name" {
|
output "container_group_name" {
|
||||||
value = azurerm_container_group.example.name
|
value = azurerm_container_group.example.name
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
terraform {
|
terraform {
|
||||||
required_version = ">=1.0"
|
required_version = ">=1.0"
|
||||||
|
|
||||||
required_providers {
|
required_providers {
|
||||||
azurerm = {
|
azurerm = {
|
||||||
source = "hashicorp/azurerm"
|
source = "hashicorp/azurerm"
|
||||||
@ -11,6 +12,7 @@ terraform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
provider "azurerm" {
|
provider "azurerm" {
|
||||||
features {}
|
features {}
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
variable "resource_group_location" {
|
|
||||||
type = string
|
|
||||||
default = "eastus"
|
|
||||||
description = "Location of the resource group."
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "resource_group_name_prefix" {
|
variable "resource_group_name_prefix" {
|
||||||
type = string
|
type = string
|
||||||
default = "rg"
|
default = "rg"
|
||||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
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."
|
||||||
}
|
}
|
Reference in New Issue
Block a user