From 6baa9203b74c2173e63dd74196b1527a80eb9586 Mon Sep 17 00:00:00 2001 From: Dingjia Chen <48020536+Pumpkin-3906@users.noreply.github.com> Date: Thu, 9 Feb 2023 20:14:32 -0600 Subject: [PATCH] 201-confidential-os-disk patch (#141) * add default value for variables; add random string for rgn --- quickstart/201-confidential-os-disk/main.tf | 10 +++++++--- quickstart/201-confidential-os-disk/outputs.tf | 7 +++++++ quickstart/201-confidential-os-disk/providers.tf | 4 ++-- quickstart/201-confidential-os-disk/variables.tf | 4 +++- 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 quickstart/201-confidential-os-disk/outputs.tf diff --git a/quickstart/201-confidential-os-disk/main.tf b/quickstart/201-confidential-os-disk/main.tf index 2060fc8a..ae4d2402 100644 --- a/quickstart/201-confidential-os-disk/main.tf +++ b/quickstart/201-confidential-os-disk/main.tf @@ -6,12 +6,12 @@ data "azurerm_platform_image" "example" { } resource "azurerm_resource_group" "example" { - name = "${var.name_prefix}-rg" + name = "${random_pet.rg_name.id}-rg" location = var.location } -resource "azurerm_managed_disk" "example" { - name = "${var.name_prefix}-disk" +resource "azurerm_managed_disk" "main" { + name = "${random_pet.rg_name.id}-disk" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name storage_account_type = "Standard_LRS" @@ -22,3 +22,7 @@ resource "azurerm_managed_disk" "example" { security_type = "ConfidentialVM_DiskEncryptedWithPlatformKey" } + +resource "random_pet" "rg_name" { + prefix = var.name_prefix +} \ No newline at end of file diff --git a/quickstart/201-confidential-os-disk/outputs.tf b/quickstart/201-confidential-os-disk/outputs.tf new file mode 100644 index 00000000..ab450506 --- /dev/null +++ b/quickstart/201-confidential-os-disk/outputs.tf @@ -0,0 +1,7 @@ +output "resource_group_name" { + value = azurerm_resource_group.example.name +} + +output "managed_disk_name" { + value = azurerm_managed_disk.main.name +} \ No newline at end of file diff --git a/quickstart/201-confidential-os-disk/providers.tf b/quickstart/201-confidential-os-disk/providers.tf index 6b2a6509..549f9c0c 100644 --- a/quickstart/201-confidential-os-disk/providers.tf +++ b/quickstart/201-confidential-os-disk/providers.tf @@ -4,11 +4,11 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "~>3.8" + version = ">= 3.0, < 4.0" } } } provider "azurerm" { features {} -} +} \ No newline at end of file diff --git a/quickstart/201-confidential-os-disk/variables.tf b/quickstart/201-confidential-os-disk/variables.tf index d0d1cc7c..4fefba47 100644 --- a/quickstart/201-confidential-os-disk/variables.tf +++ b/quickstart/201-confidential-os-disk/variables.tf @@ -1,9 +1,11 @@ variable "location" { type = string + default = "westus" description = "Location where resources will be created" } variable "name_prefix" { type = string + default = "201-confidential-os-disk" description = "Prefix of the resource name" -} +} \ No newline at end of file