Compare commits
2 Commits
301-machin
...
UserStory2
Author | SHA1 | Date | |
---|---|---|---|
7908433829 | |||
5620b3e327 |
21
quickstart/101-batch-pools-with-job/README.md
Normal file
21
quickstart/101-batch-pools-with-job/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Azure Batch
|
||||
|
||||
Deploy an Azure Batch account and two batch pools.
|
||||
|
||||
## 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_batch_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_account)
|
||||
- [azurerm_batch_pool](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_pool)
|
||||
|
||||
## 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
|
114
quickstart/101-batch-pools-with-job/main.tf
Normal file
114
quickstart/101-batch-pools-with-job/main.tf
Normal file
@ -0,0 +1,114 @@
|
||||
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" "batch_account_name" {
|
||||
length = 8
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_batch_account" "example" {
|
||||
name = random_string.batch_account_name.result
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
storage_account_id = azurerm_storage_account.example.id
|
||||
storage_account_authentication_mode = "StorageKeys"
|
||||
}
|
||||
|
||||
resource "random_pet" "azurerm_batch_pool_name" {
|
||||
prefix = "pool"
|
||||
}
|
||||
|
||||
resource "azurerm_batch_pool" "fixed" {
|
||||
name = "${random_pet.azurerm_batch_pool_name.id}-fixed-pool"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_name = azurerm_batch_account.example.name
|
||||
display_name = "Fixed Scale Pool"
|
||||
vm_size = "Standard_A1"
|
||||
node_agent_sku_id = "batch.node.ubuntu 22.04"
|
||||
|
||||
fixed_scale {
|
||||
target_dedicated_nodes = 2
|
||||
resize_timeout = "PT15M"
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
|
||||
start_task {
|
||||
command_line = "echo 'Hello World from $env'"
|
||||
task_retry_maximum = 1
|
||||
wait_for_success = true
|
||||
|
||||
common_environment_properties = {
|
||||
env = "TEST"
|
||||
}
|
||||
|
||||
user_identity {
|
||||
auto_user {
|
||||
elevation_level = "NonAdmin"
|
||||
scope = "Task"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
metadata = {
|
||||
"tagName" = "Example tag"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_batch_pool" "autopool" {
|
||||
name = "${random_pet.azurerm_batch_pool_name.id}-autoscale-pool"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_name = azurerm_batch_account.example.name
|
||||
display_name = "Auto Scale Pool"
|
||||
vm_size = "Standard_A1"
|
||||
node_agent_sku_id = "batch.node.ubuntu 22.04"
|
||||
|
||||
auto_scale {
|
||||
evaluation_interval = "PT15M"
|
||||
|
||||
formula = <<EOF
|
||||
startingNumberOfVMs = 1;
|
||||
maxNumberofVMs = 25;
|
||||
pendingTaskSamplePercent = $PendingTasks.GetSamplePercent(180 * TimeInterval_Second);
|
||||
pendingTaskSamples = pendingTaskSamplePercent < 70 ? startingNumberOfVMs : avg($PendingTasks.GetSample(180 * TimeInterval_Second));
|
||||
$TargetDedicatedNodes=min(maxNumberofVMs, pendingTaskSamples);
|
||||
EOF
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
}
|
19
quickstart/101-batch-pools-with-job/outputs.tf
Normal file
19
quickstart/101-batch-pools-with-job/outputs.tf
Normal file
@ -0,0 +1,19 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "storage_account_name" {
|
||||
value = azurerm_storage_account.example.name
|
||||
}
|
||||
|
||||
output "batch_account_name" {
|
||||
value = azurerm_batch_account.example.name
|
||||
}
|
||||
|
||||
output "batch_pool_fixed_name" {
|
||||
value = azurerm_batch_pool.fixed.name
|
||||
}
|
||||
|
||||
output "batch_pool_autopool_name" {
|
||||
value = azurerm_batch_pool.autopool.name
|
||||
}
|
18
quickstart/101-batch-pools-with-job/providers.tf
Normal file
18
quickstart/101-batch-pools-with-job/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 {}
|
||||
}
|
11
quickstart/101-batch-pools-with-job/variables.tf
Normal file
11
quickstart/101-batch-pools-with-job/variables.tf
Normal file
@ -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."
|
||||
}
|
21
quickstart/101-batch-pools-with-start-task/README.md
Normal file
21
quickstart/101-batch-pools-with-start-task/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Azure Batch with start task
|
||||
|
||||
Deploy an Azure Batch account and two batch pools, one of which has a "start task".
|
||||
|
||||
## 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_batch_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_account)
|
||||
- [azurerm_batch_pool](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_pool)
|
||||
|
||||
## 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
|
114
quickstart/101-batch-pools-with-start-task/main.tf
Normal file
114
quickstart/101-batch-pools-with-start-task/main.tf
Normal file
@ -0,0 +1,114 @@
|
||||
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" "batch_account_name" {
|
||||
length = 8
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_batch_account" "example" {
|
||||
name = random_string.batch_account_name.result
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
storage_account_id = azurerm_storage_account.example.id
|
||||
storage_account_authentication_mode = "StorageKeys"
|
||||
}
|
||||
|
||||
resource "random_pet" "azurerm_batch_pool_name" {
|
||||
prefix = "pool"
|
||||
}
|
||||
|
||||
resource "azurerm_batch_pool" "fixed" {
|
||||
name = "${random_pet.azurerm_batch_pool_name.id}-fixed-pool"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_name = azurerm_batch_account.example.name
|
||||
display_name = "Fixed Scale Pool"
|
||||
vm_size = "Standard_D4_v3"
|
||||
node_agent_sku_id = "batch.node.ubuntu 22.04"
|
||||
|
||||
fixed_scale {
|
||||
target_dedicated_nodes = 2
|
||||
resize_timeout = "PT15M"
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
|
||||
start_task {
|
||||
command_line = "echo 'Hello World from $env'"
|
||||
task_retry_maximum = 1
|
||||
wait_for_success = true
|
||||
|
||||
common_environment_properties = {
|
||||
env = "TEST"
|
||||
}
|
||||
|
||||
user_identity {
|
||||
auto_user {
|
||||
elevation_level = "NonAdmin"
|
||||
scope = "Task"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
metadata = {
|
||||
"tagName" = "Example tag"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_batch_pool" "autopool" {
|
||||
name = "${random_pet.azurerm_batch_pool_name.id}-autoscale-pool"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_name = azurerm_batch_account.example.name
|
||||
display_name = "Auto Scale Pool"
|
||||
vm_size = "Standard_D4_v3"
|
||||
node_agent_sku_id = "batch.node.ubuntu 22.04"
|
||||
|
||||
auto_scale {
|
||||
evaluation_interval = "PT15M"
|
||||
|
||||
formula = <<EOF
|
||||
startingNumberOfVMs = 1;
|
||||
maxNumberofVMs = 25;
|
||||
pendingTaskSamplePercent = $PendingTasks.GetSamplePercent(180 * TimeInterval_Second);
|
||||
pendingTaskSamples = pendingTaskSamplePercent < 70 ? startingNumberOfVMs : avg($PendingTasks.GetSample(180 * TimeInterval_Second));
|
||||
$TargetDedicatedNodes=min(maxNumberofVMs, pendingTaskSamples);
|
||||
EOF
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
}
|
19
quickstart/101-batch-pools-with-start-task/outputs.tf
Normal file
19
quickstart/101-batch-pools-with-start-task/outputs.tf
Normal file
@ -0,0 +1,19 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "storage_account_name" {
|
||||
value = azurerm_storage_account.example.name
|
||||
}
|
||||
|
||||
output "batch_account_name" {
|
||||
value = azurerm_batch_account.example.name
|
||||
}
|
||||
|
||||
output "batch_pool_fixed_name" {
|
||||
value = azurerm_batch_pool.fixed.name
|
||||
}
|
||||
|
||||
output "batch_pool_autopool_name" {
|
||||
value = azurerm_batch_pool.autopool.name
|
||||
}
|
18
quickstart/101-batch-pools-with-start-task/providers.tf
Normal file
18
quickstart/101-batch-pools-with-start-task/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 {}
|
||||
}
|
11
quickstart/101-batch-pools-with-start-task/variables.tf
Normal file
11
quickstart/101-batch-pools-with-start-task/variables.tf
Normal file
@ -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."
|
||||
}
|
@ -4,7 +4,7 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>3.0"
|
||||
version = "~>2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,15 +17,6 @@ provider "azurerm" {
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_password" "password" {
|
||||
count = var.admin_password == null ? 1 : 0
|
||||
length = 20
|
||||
}
|
||||
|
||||
locals {
|
||||
admin_password = try(random_password.password[0].result, var.admin_password)
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "vmss" {
|
||||
name = var.resource_group_name
|
||||
location = var.location
|
||||
@ -36,7 +27,7 @@ resource "random_string" "fqdn" {
|
||||
length = 6
|
||||
special = false
|
||||
upper = false
|
||||
numeric = false
|
||||
number = false
|
||||
}
|
||||
|
||||
resource "azurerm_virtual_network" "vmss" {
|
||||
@ -82,12 +73,14 @@ resource "azurerm_lb_backend_address_pool" "bpepool" {
|
||||
}
|
||||
|
||||
resource "azurerm_lb_probe" "vmss" {
|
||||
resource_group_name = azurerm_resource_group.vmss.name
|
||||
loadbalancer_id = azurerm_lb.vmss.id
|
||||
name = "ssh-running-probe"
|
||||
port = var.application_port
|
||||
}
|
||||
|
||||
resource "azurerm_lb_rule" "lbnatrule" {
|
||||
resource_group_name = azurerm_resource_group.vmss.name
|
||||
loadbalancer_id = azurerm_lb.vmss.id
|
||||
name = "http"
|
||||
protocol = "Tcp"
|
||||
@ -134,7 +127,7 @@ resource "azurerm_virtual_machine_scale_set" "vmss" {
|
||||
os_profile {
|
||||
computer_name_prefix = "vmlab"
|
||||
admin_username = var.admin_user
|
||||
admin_password = local.admin_password
|
||||
admin_password = var.admin_password
|
||||
custom_data = file("web.conf")
|
||||
}
|
||||
|
||||
@ -205,7 +198,7 @@ resource "azurerm_virtual_machine" "jumpbox" {
|
||||
os_profile {
|
||||
computer_name = "jumpbox"
|
||||
admin_username = var.admin_user
|
||||
admin_password = local.admin_password
|
||||
admin_password = var.admin_password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -28,6 +28,6 @@ variable "admin_user" {
|
||||
|
||||
variable "admin_password" {
|
||||
description = "Default password for admin account"
|
||||
default = null
|
||||
default = "ChangeMe123!"
|
||||
sensitive = true
|
||||
}
|
||||
|
@ -4,14 +4,8 @@ locals {
|
||||
hub-nva-resource-group = "hub-nva-rg"
|
||||
}
|
||||
|
||||
resource "random_string" "suffix" {
|
||||
length = 5
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "hub-nva-rg" {
|
||||
name = "${local.prefix-hub-nva}-rg-${random_string.suffix.result}"
|
||||
name = "${local.prefix-hub-nva}-rg"
|
||||
location = local.hub-nva-location
|
||||
|
||||
tags = {
|
||||
@ -61,7 +55,7 @@ resource "azurerm_virtual_machine" "hub-nva-vm" {
|
||||
os_profile {
|
||||
computer_name = "${local.prefix-hub-nva}-vm"
|
||||
admin_username = var.username
|
||||
admin_password = local.password
|
||||
admin_password = var.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
@ -84,7 +78,7 @@ resource "azurerm_virtual_machine_extension" "enable-routes" {
|
||||
settings = <<SETTINGS
|
||||
{
|
||||
"fileUris": [
|
||||
"https://raw.githubusercontent.com/lonegunmanb/reference-architectures/refs/heads/master/scripts/linux/enable-ip-forwarding.sh"
|
||||
"https://raw.githubusercontent.com/mspnp/reference-architectures/master/scripts/linux/enable-ip-forwarding.sh"
|
||||
],
|
||||
"commandToExecute": "bash enable-ip-forwarding.sh"
|
||||
}
|
||||
@ -148,7 +142,7 @@ resource "azurerm_route_table" "spoke1-rt" {
|
||||
route {
|
||||
name = "default"
|
||||
address_prefix = "0.0.0.0/0"
|
||||
next_hop_type = "VnetLocal"
|
||||
next_hop_type = "vnetlocal"
|
||||
}
|
||||
|
||||
tags = {
|
||||
@ -184,7 +178,7 @@ resource "azurerm_route_table" "spoke2-rt" {
|
||||
route {
|
||||
name = "default"
|
||||
address_prefix = "0.0.0.0/0"
|
||||
next_hop_type = "VnetLocal"
|
||||
next_hop_type = "vnetlocal"
|
||||
}
|
||||
|
||||
tags = {
|
||||
|
@ -1,7 +1,7 @@
|
||||
locals {
|
||||
prefix-hub = "hub"
|
||||
hub-location = "eastus"
|
||||
hub-resource-group = "hub-vnet-rg-${random_string.suffix.result}"
|
||||
hub-resource-group = "hub-vnet-rg"
|
||||
shared-key = "4-v3ry-53cr37-1p53c-5h4r3d-k3y"
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ resource "azurerm_virtual_machine" "hub-vm" {
|
||||
os_profile {
|
||||
computer_name = "${local.prefix-hub}-vm"
|
||||
admin_username = var.username
|
||||
admin_password = local.password
|
||||
admin_password = var.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -5,24 +5,11 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
version = "~>2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {
|
||||
resource_group {
|
||||
prevent_deletion_if_contains_resources = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_password" "password" {
|
||||
count = var.password == null ? 1 : 0
|
||||
length = 20
|
||||
}
|
||||
|
||||
locals {
|
||||
password = try(random_password.password[0].result, var.password)
|
||||
features {}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
locals {
|
||||
onprem-location = "eastus"
|
||||
onprem-resource-group = "onprem-vnet-rg-${random_string.suffix.result}"
|
||||
onprem-resource-group = "onprem-vnet-rg"
|
||||
prefix-onprem = "onprem"
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ resource "azurerm_virtual_machine" "onprem-vm" {
|
||||
os_profile {
|
||||
computer_name = "${local.prefix-onprem}-vm"
|
||||
admin_username = var.username
|
||||
admin_password = local.password
|
||||
admin_password = var.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -1,6 +1,6 @@
|
||||
locals {
|
||||
spoke1-location = "eastus"
|
||||
spoke1-resource-group = "spoke1-vnet-rg-${random_string.suffix.result}"
|
||||
spoke1-resource-group = "spoke1-vnet-rg"
|
||||
prefix-spoke1 = "spoke1"
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ resource "azurerm_virtual_machine" "spoke1-vm" {
|
||||
os_profile {
|
||||
computer_name = "${local.prefix-spoke1}-vm"
|
||||
admin_username = var.username
|
||||
admin_password = local.password
|
||||
admin_password = var.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -1,6 +1,6 @@
|
||||
locals {
|
||||
spoke2-location = "eastus"
|
||||
spoke2-resource-group = "spoke2-vnet-rg-${random_string.suffix.result}"
|
||||
spoke2-resource-group = "spoke2-vnet-rg"
|
||||
prefix-spoke2 = "spoke2"
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ resource "azurerm_virtual_machine" "spoke2-vm" {
|
||||
os_profile {
|
||||
computer_name = "${local.prefix-spoke2}-vm"
|
||||
admin_username = var.username
|
||||
admin_password = local.password
|
||||
admin_password = var.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -10,8 +10,6 @@ variable "username" {
|
||||
|
||||
variable "password" {
|
||||
description = "Password for Virtual Machines"
|
||||
sensitive = true
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vmsize" {
|
||||
|
@ -3,7 +3,7 @@ resource "random_string" "fw_diag_prefix" {
|
||||
length = 8
|
||||
upper = false
|
||||
special = false
|
||||
numeric = false
|
||||
number = false
|
||||
}
|
||||
resource "azurerm_ip_group" "ip_group_hub" {
|
||||
name = "hub-ipgroup"
|
||||
@ -47,8 +47,6 @@ resource "azurerm_firewall" "azure_firewall_instance" {
|
||||
name = "afw-${var.name}-${var.environment}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.hub_rg.name
|
||||
sku_name = "AZFW_VNet"
|
||||
sku_tier = "Standard"
|
||||
firewall_policy_id = azurerm_firewall_policy.base_policy.id
|
||||
|
||||
ip_configuration {
|
||||
@ -107,11 +105,6 @@ resource "azurerm_monitor_diagnostic_setting" "azure_firewall_instance" {
|
||||
}
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
log
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_firewall_policy_rule_collection_group" "azure_firewall_rules_collection" {
|
||||
|
@ -3,7 +3,7 @@ resource "random_string" "ci_prefix" {
|
||||
length = 8
|
||||
upper = false
|
||||
special = false
|
||||
numeric = false
|
||||
number = false
|
||||
}
|
||||
|
||||
# Compute instance
|
||||
|
@ -10,15 +10,6 @@ resource "azurerm_network_interface" "dsvm" {
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_password" "dsvm_host_password" {
|
||||
count = var.dsvm_host_password == null ? 1 : 0
|
||||
length = 20
|
||||
}
|
||||
|
||||
locals {
|
||||
dsvm_host_password = try(random_password.dsvm_host_password[0].result, var.dsvm_host_password)
|
||||
}
|
||||
|
||||
resource "azurerm_windows_virtual_machine" "dsvm" {
|
||||
name = var.dsvm_name
|
||||
location = azurerm_resource_group.default.location
|
||||
@ -46,18 +37,12 @@ resource "azurerm_windows_virtual_machine" "dsvm" {
|
||||
}
|
||||
computer_name = var.dsvm_name
|
||||
admin_username = var.dsvm_admin_username
|
||||
admin_password = local.dsvm_host_password
|
||||
admin_password = var.dsvm_host_password
|
||||
|
||||
provision_vm_agent = true
|
||||
vm_agent_platform_updates_enabled = false
|
||||
|
||||
timeouts {
|
||||
create = "60m"
|
||||
delete = "2h"
|
||||
}
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
vm_agent_platform_updates_enabled,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -4,43 +4,29 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
version = "=2.78.0"
|
||||
}
|
||||
|
||||
azureml = {
|
||||
source = "registry.terraform.io/orobix/azureml"
|
||||
source = "registry.terraform.io/Telemaco019/azureml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {
|
||||
key_vault {
|
||||
recover_soft_deleted_key_vaults = false
|
||||
purge_soft_delete_on_destroy = false
|
||||
purge_soft_deleted_keys_on_destroy = false
|
||||
}
|
||||
resource_group {
|
||||
prevent_deletion_if_contains_resources = false
|
||||
}
|
||||
}
|
||||
features {}
|
||||
}
|
||||
|
||||
data "azurerm_client_config" "current" {}
|
||||
|
||||
resource "random_string" "suffix" {
|
||||
length = 4
|
||||
upper = false
|
||||
special = false
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "default" {
|
||||
name = "rg-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
name = "rg-${var.name}-${var.environment}"
|
||||
location = var.location
|
||||
}
|
||||
|
||||
#Hub Resource Group
|
||||
resource "azurerm_resource_group" "hub_rg" {
|
||||
name = "rg-hub-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
name = "rg-hub-${var.name}-${var.environment}"
|
||||
location = var.location
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
variable "name" {
|
||||
type = string
|
||||
description = "Name of the deployment"
|
||||
default = "301mlhss"
|
||||
}
|
||||
|
||||
variable "environment" {
|
||||
@ -91,5 +90,4 @@ variable "dsvm_host_password" {
|
||||
type = string
|
||||
description = "Password for the admin username of the Data Science VM"
|
||||
sensitive = true
|
||||
default = null
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
# Dependent resources for Azure Machine Learning
|
||||
resource "azurerm_application_insights" "default" {
|
||||
name = "appi-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
name = "appi-${var.name}-${var.environment}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
workspace_id = azurerm_log_analytics_workspace.default.id
|
||||
@ -8,7 +8,7 @@ resource "azurerm_application_insights" "default" {
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault" "default" {
|
||||
name = "kv-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
name = "kv-${var.name}-${var.environment}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
@ -22,7 +22,7 @@ resource "azurerm_key_vault" "default" {
|
||||
}
|
||||
|
||||
resource "azurerm_storage_account" "default" {
|
||||
name = "st${var.name}${var.environment}${random_string.suffix.result}"
|
||||
name = "st${var.name}${var.environment}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
account_tier = "Standard"
|
||||
@ -36,7 +36,7 @@ resource "azurerm_storage_account" "default" {
|
||||
}
|
||||
|
||||
resource "azurerm_container_registry" "default" {
|
||||
name = "cr${var.name}${var.environment}${random_string.suffix.result}"
|
||||
name = "cr${var.name}${var.environment}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
sku = "Premium"
|
||||
@ -50,7 +50,7 @@ resource "azurerm_container_registry" "default" {
|
||||
|
||||
# Machine Learning workspace
|
||||
resource "azurerm_machine_learning_workspace" "default" {
|
||||
name = "mlw-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
name = "mlw-${var.name}-${var.environment}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
application_insights_id = azurerm_application_insights.default.id
|
||||
@ -76,13 +76,6 @@ resource "azurerm_machine_learning_workspace" "default" {
|
||||
|
||||
}
|
||||
|
||||
resource "time_sleep" "one_min" {
|
||||
create_duration = "1m"
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.dsvm
|
||||
]
|
||||
}
|
||||
|
||||
# Private endpoints
|
||||
resource "azurerm_private_endpoint" "kv_ple" {
|
||||
name = "ple-${var.name}-${var.environment}-kv"
|
||||
@ -101,9 +94,6 @@ resource "azurerm_private_endpoint" "kv_ple" {
|
||||
subresource_names = ["vault"]
|
||||
is_manual_connection = false
|
||||
}
|
||||
depends_on = [
|
||||
time_sleep.one_min
|
||||
]
|
||||
}
|
||||
|
||||
resource "azurerm_private_endpoint" "st_ple_blob" {
|
||||
@ -123,9 +113,6 @@ resource "azurerm_private_endpoint" "st_ple_blob" {
|
||||
subresource_names = ["blob"]
|
||||
is_manual_connection = false
|
||||
}
|
||||
depends_on = [
|
||||
time_sleep.one_min
|
||||
]
|
||||
}
|
||||
|
||||
resource "azurerm_private_endpoint" "storage_ple_file" {
|
||||
@ -145,9 +132,6 @@ resource "azurerm_private_endpoint" "storage_ple_file" {
|
||||
subresource_names = ["file"]
|
||||
is_manual_connection = false
|
||||
}
|
||||
depends_on = [
|
||||
time_sleep.one_min
|
||||
]
|
||||
}
|
||||
|
||||
resource "azurerm_private_endpoint" "cr_ple" {
|
||||
@ -167,9 +151,6 @@ resource "azurerm_private_endpoint" "cr_ple" {
|
||||
subresource_names = ["registry"]
|
||||
is_manual_connection = false
|
||||
}
|
||||
depends_on = [
|
||||
time_sleep.one_min
|
||||
]
|
||||
}
|
||||
|
||||
resource "azurerm_private_endpoint" "mlw_ple" {
|
||||
@ -189,9 +170,6 @@ resource "azurerm_private_endpoint" "mlw_ple" {
|
||||
subresource_names = ["amlworkspace"]
|
||||
is_manual_connection = false
|
||||
}
|
||||
depends_on = [
|
||||
time_sleep.one_min
|
||||
]
|
||||
}
|
||||
|
||||
# Compute cluster for image building required since the workspace is behind a vnet.
|
||||
|
Reference in New Issue
Block a user