diff --git a/quickstart/201-machine-learning-moderately-secure/compute.tf b/quickstart/201-machine-learning-moderately-secure/compute.tf index e5be7fbb8..1d32a075a 100644 --- a/quickstart/201-machine-learning-moderately-secure/compute.tf +++ b/quickstart/201-machine-learning-moderately-secure/compute.tf @@ -3,7 +3,7 @@ resource "random_string" "ci_prefix" { length = 8 upper = false special = false - number = false + numeric = false } # Compute instance diff --git a/quickstart/201-machine-learning-moderately-secure/dsvm.tf b/quickstart/201-machine-learning-moderately-secure/dsvm.tf index d01ddebe6..7d75c9498 100644 --- a/quickstart/201-machine-learning-moderately-secure/dsvm.tf +++ b/quickstart/201-machine-learning-moderately-secure/dsvm.tf @@ -10,10 +10,16 @@ resource "azurerm_network_interface" "dsvm" { } } +resource "random_password" "vm" { + count = var.dsvm_host_password == null ? 1 : 0 + + length = 20 +} + resource "azurerm_windows_virtual_machine" "dsvm" { - name = var.dsvm_name - location = azurerm_resource_group.default.location - resource_group_name = azurerm_resource_group.default.name + name = var.dsvm_name + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name network_interface_ids = [ azurerm_network_interface.dsvm.id ] @@ -37,7 +43,7 @@ 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 = try(random_password.vm[0].result, var.dsvm_host_password) provision_vm_agent = true diff --git a/quickstart/201-machine-learning-moderately-secure/main.tf b/quickstart/201-machine-learning-moderately-secure/main.tf index e66e68f67..c1e908358 100644 --- a/quickstart/201-machine-learning-moderately-secure/main.tf +++ b/quickstart/201-machine-learning-moderately-secure/main.tf @@ -4,22 +4,28 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "=3.0.2" + version = "~>3.0" } - - azureml = { - source = "registry.terraform.io/orobix/azureml" + random = { + source = "hashicorp/random" + version = ">=3.4.3" } } } provider "azurerm" { - features {} + features { + resource_group { + prevent_deletion_if_contains_resources = false + } + } } data "azurerm_client_config" "current" {} +resource "random_pet" "suffix" {} + resource "azurerm_resource_group" "default" { - name = "rg-${var.name}-${var.environment}" + name = "rg-${var.name}-${var.environment}-${random_pet.suffix.id}" location = var.location } diff --git a/quickstart/201-machine-learning-moderately-secure/outputs.tf b/quickstart/201-machine-learning-moderately-secure/outputs.tf new file mode 100644 index 000000000..1e4e1bd70 --- /dev/null +++ b/quickstart/201-machine-learning-moderately-secure/outputs.tf @@ -0,0 +1,4 @@ +output "dsvm_admin_password" { + sensitive = true + value = azurerm_windows_virtual_machine.dsvm.admin_password +} \ No newline at end of file diff --git a/quickstart/201-machine-learning-moderately-secure/variables.tf b/quickstart/201-machine-learning-moderately-secure/variables.tf index fb8299d2a..a4630a2f6 100644 --- a/quickstart/201-machine-learning-moderately-secure/variables.tf +++ b/quickstart/201-machine-learning-moderately-secure/variables.tf @@ -1,6 +1,7 @@ variable "name" { type = string description = "Name of the deployment" + default = "ml-secure" } variable "environment" { @@ -70,6 +71,7 @@ variable "dsvm_admin_username" { variable "dsvm_host_password" { type = string - description = "Password for the admin username of the Data Science VM" + description = "Password for the admin username of the Data Science VM. Leave blank to generate a random password" + default = null sensitive = true } \ No newline at end of file diff --git a/quickstart/201-machine-learning-moderately-secure/workspace.tf b/quickstart/201-machine-learning-moderately-secure/workspace.tf index 7b6ba44af..4c4752534 100644 --- a/quickstart/201-machine-learning-moderately-secure/workspace.tf +++ b/quickstart/201-machine-learning-moderately-secure/workspace.tf @@ -6,8 +6,14 @@ resource "azurerm_application_insights" "default" { application_type = "web" } +resource "random_string" "kv_suffix" { + length = 24 + upper = false + special = false +} + resource "azurerm_key_vault" "default" { - name = "kv-${var.name}-${var.environment}" + name = substr("kv-${var.name}-${var.environment}-${random_string.kv_suffix.result}", 0, 24) location = azurerm_resource_group.default.location resource_group_name = azurerm_resource_group.default.name tenant_id = data.azurerm_client_config.current.tenant_id @@ -20,8 +26,14 @@ resource "azurerm_key_vault" "default" { } } +resource "random_string" "storage_suffix" { + length = 4 + upper = false + special = false +} + resource "azurerm_storage_account" "default" { - name = "st${var.name}${var.environment}" + name = replace("st${var.name}${var.environment}${random_string.storage_suffix.result}", "-", "") location = azurerm_resource_group.default.location resource_group_name = azurerm_resource_group.default.name account_tier = "Standard" @@ -33,8 +45,14 @@ resource "azurerm_storage_account" "default" { } } +resource "random_string" "cr_suffix" { + length = 4 + upper = false + special = false +} + resource "azurerm_container_registry" "default" { - name = "cr${var.name}${var.environment}" + name = replace("cr${var.name}${var.environment}${random_string.cr_suffix.result}", "-", "") location = azurerm_resource_group.default.location resource_group_name = azurerm_resource_group.default.name sku = "Premium" @@ -63,7 +81,7 @@ resource "azurerm_machine_learning_workspace" "default" { # Args of use when using an Azure Private Link configuration public_network_access_enabled = false image_build_compute_name = var.image_build_compute_name - depends_on = [ + depends_on = [ azurerm_private_endpoint.kv_ple, azurerm_private_endpoint.st_ple_blob, azurerm_private_endpoint.storage_ple_file, diff --git a/test/go.mod b/test/go.mod index 8dae61f84..28f78e97e 100644 --- a/test/go.mod +++ b/test/go.mod @@ -3,17 +3,20 @@ module github.com/Azure/terraform go 1.19 require ( - github.com/Azure/terraform-module-test-helper v0.8.0 - github.com/gruntwork-io/terratest v0.41.9 + github.com/Azure/terraform-module-test-helper v0.13.0 + github.com/gruntwork-io/terratest v0.41.17 ) require ( - cloud.google.com/go v0.83.0 // indirect - cloud.google.com/go/storage v1.14.0 // indirect + cloud.google.com/go v0.105.0 // indirect + cloud.google.com/go/compute v1.12.1 // indirect + cloud.google.com/go/compute/metadata v0.2.1 // indirect + cloud.google.com/go/iam v0.7.0 // indirect + cloud.google.com/go/storage v1.27.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/ahmetb/go-linq/v3 v3.2.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/aws/aws-sdk-go v1.40.56 // indirect + github.com/aws/aws-sdk-go v1.44.122 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect @@ -23,40 +26,39 @@ require ( github.com/go-logr/logr v0.2.0 // indirect github.com/go-sql-driver/mysql v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/golang/snappy v0.0.3 // indirect - github.com/google/go-cmp v0.5.8 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-github/v42 v42.0.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.1.0 // indirect - github.com/google/uuid v1.2.0 // indirect - github.com/googleapis/gax-go/v2 v2.0.5 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect + github.com/googleapis/gax-go/v2 v2.7.0 // indirect github.com/googleapis/gnostic v0.4.1 // indirect github.com/gruntwork-io/go-commons v0.8.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.6.1 // indirect - github.com/hashicorp/go-getter/v2 v2.1.1 // indirect + github.com/hashicorp/go-getter v1.7.1 // indirect + github.com/hashicorp/go-getter/v2 v2.2.1 // indirect github.com/hashicorp/go-multierror v1.1.0 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-version v1.5.0 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/hcl/v2 v2.15.0 // indirect + github.com/hashicorp/hcl/v2 v2.16.2 // indirect github.com/hashicorp/terraform-config-inspect v0.0.0-20211115214459-90acf1ca460f // indirect - github.com/hashicorp/terraform-json v0.14.0 // indirect + github.com/hashicorp/terraform-json v0.16.0 // indirect github.com/imdario/mergo v0.3.11 // indirect github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/json-iterator/go v1.1.11 // indirect - github.com/jstemmer/go-junit-report v0.9.1 // indirect - github.com/klauspost/compress v1.13.0 // indirect + github.com/klauspost/compress v1.15.11 // indirect github.com/lonegunmanb/tfmodredirector v0.1.0 // indirect github.com/magodo/hclgrep v0.0.0-20220303061548-1b2b24c7caf6 // indirect github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect github.com/minamijoyo/hcledit v0.2.6 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/go-testing-interface v1.0.0 // indirect + github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect @@ -64,32 +66,30 @@ require ( github.com/pquerna/otp v1.2.0 // indirect github.com/r3labs/diff/v3 v3.0.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/spf13/afero v1.9.3 // indirect + github.com/spf13/afero v1.9.5 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/testify v1.8.1 // indirect + github.com/stretchr/testify v1.8.2 // indirect github.com/tmccombs/hcl2json v0.3.3 // indirect - github.com/ulikunitz/xz v0.5.8 // indirect + github.com/ulikunitz/xz v0.5.10 // indirect github.com/urfave/cli v1.22.2 // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.12.1 // indirect - go.opencensus.io v0.23.0 // indirect - golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 // indirect - golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect - golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect - golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect - golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect - golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect - golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect - golang.org/x/text v0.3.7 // indirect + github.com/zclconf/go-cty v1.13.0 // indirect + go.opencensus.io v0.24.0 // indirect + golang.org/x/crypto v0.1.0 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/net v0.9.0 // indirect + golang.org/x/oauth2 v0.7.0 // indirect + golang.org/x/sys v0.7.0 // indirect + golang.org/x/term v0.7.0 // indirect + golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect - golang.org/x/tools v0.1.10 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/api v0.47.0 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/api v0.103.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect - google.golang.org/grpc v1.38.0 // indirect - google.golang.org/protobuf v1.26.0 // indirect + google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c // indirect + google.golang.org/grpc v1.51.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect