Compare commits
26 Commits
101-authn-
...
301-machin
Author | SHA1 | Date | |
---|---|---|---|
5e5d975f67 | |||
30e5ac224b | |||
73c1ca51f1 | |||
0a6ee4d6d3 | |||
ee8733602b | |||
3e8e2078ab | |||
a43c127c8e | |||
4bb8b212ac | |||
64e270d463 | |||
fd903819cd | |||
91b73244e5 | |||
77dcd8d154 | |||
c3ecd139eb | |||
7c6d6f9438 | |||
181b34291c | |||
1b713632d1 | |||
96cd33dea4 | |||
376f0a3732 | |||
e07726ef45 | |||
8c3f290e61 | |||
3a6dd12ab9 | |||
5192273700 | |||
d2e47ddadd | |||
96d88c3c41 | |||
e405273660 | |||
98f857a865 |
@ -40,4 +40,13 @@ resource "azurerm_attestation_provider" "corp_attestation" {
|
||||
name = "${var.attestation_provider_name}${random_string.attestation_suffix.result}"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
policy_signing_certificate_data = try(tls_self_signed_cert.attestation[0].cert_pem, file(var.cert_path))
|
||||
#https://github.com/hashicorp/terraform-provider-azurerm/issues/21998#issuecomment-1573312297
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
"open_enclave_policy_base64",
|
||||
"sev_snp_policy_base64",
|
||||
"sgx_enclave_policy_base64",
|
||||
"tpm_policy_base64",
|
||||
]
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
|
@ -3,7 +3,7 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
|
@ -8,7 +8,7 @@ terraform {
|
||||
}
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
|
@ -4,7 +4,7 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,15 @@ 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
|
||||
@ -27,7 +36,7 @@ resource "random_string" "fqdn" {
|
||||
length = 6
|
||||
special = false
|
||||
upper = false
|
||||
number = false
|
||||
numeric = false
|
||||
}
|
||||
|
||||
resource "azurerm_virtual_network" "vmss" {
|
||||
@ -73,14 +82,12 @@ 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"
|
||||
@ -127,7 +134,7 @@ resource "azurerm_virtual_machine_scale_set" "vmss" {
|
||||
os_profile {
|
||||
computer_name_prefix = "vmlab"
|
||||
admin_username = var.admin_user
|
||||
admin_password = var.admin_password
|
||||
admin_password = local.admin_password
|
||||
custom_data = file("web.conf")
|
||||
}
|
||||
|
||||
@ -198,7 +205,7 @@ resource "azurerm_virtual_machine" "jumpbox" {
|
||||
os_profile {
|
||||
computer_name = "jumpbox"
|
||||
admin_username = var.admin_user
|
||||
admin_password = var.admin_password
|
||||
admin_password = local.admin_password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -28,6 +28,6 @@ variable "admin_user" {
|
||||
|
||||
variable "admin_password" {
|
||||
description = "Default password for admin account"
|
||||
default = "ChangeMe123!"
|
||||
default = null
|
||||
sensitive = true
|
||||
}
|
||||
|
@ -4,8 +4,14 @@ 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"
|
||||
name = "${local.prefix-hub-nva}-rg-${random_string.suffix.result}"
|
||||
location = local.hub-nva-location
|
||||
|
||||
tags = {
|
||||
@ -55,7 +61,7 @@ resource "azurerm_virtual_machine" "hub-nva-vm" {
|
||||
os_profile {
|
||||
computer_name = "${local.prefix-hub-nva}-vm"
|
||||
admin_username = var.username
|
||||
admin_password = var.password
|
||||
admin_password = local.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
@ -78,7 +84,7 @@ resource "azurerm_virtual_machine_extension" "enable-routes" {
|
||||
settings = <<SETTINGS
|
||||
{
|
||||
"fileUris": [
|
||||
"https://raw.githubusercontent.com/mspnp/reference-architectures/master/scripts/linux/enable-ip-forwarding.sh"
|
||||
"https://raw.githubusercontent.com/lonegunmanb/reference-architectures/refs/heads/master/scripts/linux/enable-ip-forwarding.sh"
|
||||
],
|
||||
"commandToExecute": "bash enable-ip-forwarding.sh"
|
||||
}
|
||||
@ -142,7 +148,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 = {
|
||||
@ -178,7 +184,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"
|
||||
hub-resource-group = "hub-vnet-rg-${random_string.suffix.result}"
|
||||
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 = var.password
|
||||
admin_password = local.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -5,11 +5,24 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
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)
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
locals {
|
||||
onprem-location = "eastus"
|
||||
onprem-resource-group = "onprem-vnet-rg"
|
||||
onprem-resource-group = "onprem-vnet-rg-${random_string.suffix.result}"
|
||||
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 = var.password
|
||||
admin_password = local.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -1,6 +1,6 @@
|
||||
locals {
|
||||
spoke1-location = "eastus"
|
||||
spoke1-resource-group = "spoke1-vnet-rg"
|
||||
spoke1-resource-group = "spoke1-vnet-rg-${random_string.suffix.result}"
|
||||
prefix-spoke1 = "spoke1"
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ resource "azurerm_virtual_network_peering" "spoke1-hub-peer" {
|
||||
allow_forwarded_traffic = true
|
||||
allow_gateway_transit = false
|
||||
use_remote_gateways = true
|
||||
depends_on = [azurerm_virtual_network.spoke1-vnet, azurerm_virtual_network.hub-vnet , azurerm_virtual_network_gateway.hub-vnet-gateway]
|
||||
depends_on = [azurerm_virtual_network.spoke1-vnet, azurerm_virtual_network.hub-vnet, azurerm_virtual_network_gateway.hub-vnet-gateway]
|
||||
}
|
||||
|
||||
resource "azurerm_network_interface" "spoke1-nic" {
|
||||
@ -84,7 +84,7 @@ resource "azurerm_virtual_machine" "spoke1-vm" {
|
||||
os_profile {
|
||||
computer_name = "${local.prefix-spoke1}-vm"
|
||||
admin_username = var.username
|
||||
admin_password = var.password
|
||||
admin_password = local.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -1,6 +1,6 @@
|
||||
locals {
|
||||
spoke2-location = "eastus"
|
||||
spoke2-resource-group = "spoke2-vnet-rg"
|
||||
spoke2-resource-group = "spoke2-vnet-rg-${random_string.suffix.result}"
|
||||
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 = var.password
|
||||
admin_password = local.password
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
|
@ -10,6 +10,8 @@ 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
|
||||
number = false
|
||||
numeric = false
|
||||
}
|
||||
resource "azurerm_ip_group" "ip_group_hub" {
|
||||
name = "hub-ipgroup"
|
||||
@ -47,6 +47,8 @@ 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 {
|
||||
@ -105,6 +107,11 @@ 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
|
||||
number = false
|
||||
numeric = false
|
||||
}
|
||||
|
||||
# Compute instance
|
||||
|
@ -10,6 +10,15 @@ 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
|
||||
@ -37,12 +46,18 @@ resource "azurerm_windows_virtual_machine" "dsvm" {
|
||||
}
|
||||
computer_name = var.dsvm_name
|
||||
admin_username = var.dsvm_admin_username
|
||||
admin_password = var.dsvm_host_password
|
||||
admin_password = local.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,29 +4,43 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "=2.78.0"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
|
||||
azureml = {
|
||||
source = "registry.terraform.io/Telemaco019/azureml"
|
||||
source = "registry.terraform.io/orobix/azureml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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}"
|
||||
name = "rg-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
location = var.location
|
||||
}
|
||||
|
||||
#Hub Resource Group
|
||||
resource "azurerm_resource_group" "hub_rg" {
|
||||
name = "rg-hub-${var.name}-${var.environment}"
|
||||
name = "rg-hub-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
location = var.location
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
variable "name" {
|
||||
type = string
|
||||
description = "Name of the deployment"
|
||||
default = "301mlhss"
|
||||
}
|
||||
|
||||
variable "environment" {
|
||||
@ -90,4 +91,5 @@ 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}"
|
||||
name = "appi-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
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}"
|
||||
name = "kv-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
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}"
|
||||
name = "st${var.name}${var.environment}${random_string.suffix.result}"
|
||||
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}"
|
||||
name = "cr${var.name}${var.environment}${random_string.suffix.result}"
|
||||
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}"
|
||||
name = "mlw-${var.name}-${var.environment}-${random_string.suffix.result}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
application_insights_id = azurerm_application_insights.default.id
|
||||
@ -76,6 +76,13 @@ 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"
|
||||
@ -94,6 +101,9 @@ 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" {
|
||||
@ -113,6 +123,9 @@ 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" {
|
||||
@ -132,6 +145,9 @@ 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" {
|
||||
@ -151,6 +167,9 @@ 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" {
|
||||
@ -170,6 +189,9 @@ 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