-
Notifications
You must be signed in to change notification settings - Fork 826
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #258 from pauljewellmsft/amlfs-sample
Add Terraform code for deploying Azure Managed Lustre file system
- Loading branch information
Showing
5 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
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,29 @@ | ||
# Azure Managed Lustre | ||
This template deploys an Azure Managed Lustre file system. | ||
|
||
## Terraform resource types | ||
|
||
- [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) | ||
- [azurerm_managed_lustre_file_system](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/managed_lustre_file_system) | ||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | ||
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | ||
|
||
## 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. | "" | | ||
| `amlfs_name` | Name of the Managed Lustre file system resource. | "" | | ||
| `amlfs_sku_name` | SKU name for the Azure Managed Lustre file system. Possible values are: AMLFS-Durable-Premium-40, AMLFS-Durable-Premium-125, AMLFS-Durable-Premium-250, and AMLFS-Durable-Premium-500. | AMLFS-Durable-Premium-40 | | ||
| `amlfs_storage_capacity_in_tb` | The size of the AML file system, in TiB. This might be rounded up. | 48 | | ||
| `amlfs_maintenance_day_of_week` | Day of the week on which the maintenance window will occur. Possible values are: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. | Saturday | | ||
| `amlfs_maintenance_time_of_day` | The time of day (in UTC) to start the maintenance window. | 02:00 | | ||
|
||
## Example | ||
|
||
To see how to run this example, see [Create an Azure Managed Lustre file system using Terraform](https://learn.microsoft.com/azure/azure-managed-lustre/create-aml-file-system-terraform). |
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,60 @@ | ||
resource "random_pet" "rg_name" { | ||
prefix = var.resource_group_name_prefix | ||
} | ||
|
||
resource "azurerm_resource_group" "rg" { | ||
name = "${random_pet.rg_name.id}" | ||
location = var.resource_group_location | ||
} | ||
|
||
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"] | ||
} | ||
|
||
resource "random_string" "azurerm_amlfs_name" { | ||
length = 13 | ||
lower = true | ||
numeric = false | ||
special = false | ||
upper = false | ||
} | ||
|
||
resource "azurerm_managed_lustre_file_system" "example" { | ||
name = coalesce(var.amlfs_name, "amlfs-${random_string.azurerm_amlfs_name.result}") | ||
resource_group_name = azurerm_resource_group.rg.name | ||
location = azurerm_resource_group.rg.location | ||
sku_name = var.amlfs_sku_name | ||
subnet_id = azurerm_subnet.example.id | ||
storage_capacity_in_tb = var.amlfs_storage_capacity_in_tb | ||
zones = ["1"] | ||
maintenance_window { | ||
day_of_week = var.amlfs_maintenance_day_of_week | ||
time_of_day_in_utc = var.amlfs_maintenance_time_of_day | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
quickstart/101-managed-lustre-create-filesystem/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,23 @@ | ||
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 "azurerm_managed_lustre_file_system" { | ||
value = azurerm_managed_lustre_file_system.example.name | ||
} | ||
|
||
output "amlfs_sku_name" { | ||
value = azurerm_managed_lustre_file_system.example.sku_name | ||
} | ||
|
||
output "amlfs_storage_capacity_in_tb" { | ||
value = azurerm_managed_lustre_file_system.example.storage_capacity_in_tb | ||
} |
18 changes: 18 additions & 0 deletions
18
quickstart/101-managed-lustre-create-filesystem/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,18 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~> 3.0, < 4.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = "~> 3.0" | ||
} | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
features {} | ||
} |
61 changes: 61 additions & 0 deletions
61
quickstart/101-managed-lustre-create-filesystem/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,61 @@ | ||
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 "amlfs_name" { | ||
type = string | ||
description = "The name of the Manage Lustre file system resource. The value will be randomly generated if blank." | ||
default = "" | ||
} | ||
|
||
variable "amlfs_sku_name" { | ||
type = string | ||
default = "AMLFS-Durable-Premium-40" | ||
validation { | ||
condition = contains(["AMLFS-Durable-Premium-40", "AMLFS-Durable-Premium-125", "AMLFS-Durable-Premium-250", "AMLFS-Durable-Premium-500"], var.amlfs_sku_name) | ||
error_message = "The SKU value must be one of the following: AMLFS-Durable-Premium-40, AMLFS-Durable-Premium-125, AMLFS-Durable-Premium-250, AMLFS-Durable-Premium-500." | ||
} | ||
description = "SKU name for the Azure Managed Lustre file system." | ||
} | ||
|
||
variable "amlfs_storage_capacity_in_tb" { | ||
type = number | ||
default = 48 | ||
description = "The size of the Managed Lustre file system, in TiB. This might be rounded up." | ||
} | ||
|
||
variable "amlfs_maintenance_day_of_week" { | ||
type = string | ||
default = "Saturday" | ||
validation { | ||
condition = contains(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], var.amlfs_maintenance_day_of_week) | ||
error_message = "The maintenance day of week value must be one of the following: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday." | ||
} | ||
description = "Day of the week on which the maintenance window will occur." | ||
} | ||
|
||
variable "amlfs_maintenance_time_of_day" { | ||
type = string | ||
default = "02:00" | ||
description = "The time of day (in UTC) to start the maintenance window." | ||
} |