Skip to content

Fix 201-machine-learning-moderately-secure #198

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

Open
wants to merge 4 commits 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "random_string" "ci_prefix" {
length = 8
upper = false
special = false
number = false
numeric = false
}

# Compute instance
Expand Down
14 changes: 10 additions & 4 deletions quickstart/201-machine-learning-moderately-secure/dsvm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand All @@ -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

Expand Down
18 changes: 12 additions & 6 deletions quickstart/201-machine-learning-moderately-secure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions quickstart/201-machine-learning-moderately-secure/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "dsvm_admin_password" {
sensitive = true
value = azurerm_windows_virtual_machine.dsvm.admin_password
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
variable "name" {
type = string
description = "Name of the deployment"
default = "ml-secure"
}

variable "environment" {
Expand Down Expand Up @@ -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
}
26 changes: 22 additions & 4 deletions quickstart/201-machine-learning-moderately-secure/workspace.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
74 changes: 37 additions & 37 deletions test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,73 +26,70 @@ 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
github.com/pmezard/go-difflib v1.0.0 // indirect
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
Expand Down