Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Story 327082 - 101-container-instance-volume-mount #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions quickstart/101-container-instance-volume-mount/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Azure Container Instance with Azure File Share

This template deploys an Azure Container Instance with an Azure File Share as a volume mount.

## 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)
- [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)

## 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 |

## Example
81 changes: 81 additions & 0 deletions quickstart/101-container-instance-volume-mount/main.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
23 changes: 23 additions & 0 deletions quickstart/101-container-instance-volume-mount/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
output "resource_group_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" {
value = azurerm_container_group.example.name
}

output "ip_address" {
value = azurerm_container_group.example.ip_address
}

output "fqdn" {
value = azurerm_container_group.example.fqdn
}
18 changes: 18 additions & 0 deletions quickstart/101-container-instance-volume-mount/providers.tf
Original file line number Diff line number Diff line change
@@ -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 {}
}
11 changes: 11 additions & 0 deletions quickstart/101-container-instance-volume-mount/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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."
}
Loading