201-confidential-os-disk patch (#141)

* add default value for variables; add random string for rgn
This commit is contained in:
Dingjia Chen 2023-02-09 20:14:32 -06:00 committed by GitHub
parent dd30e9384e
commit 6baa9203b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 6 deletions

View File

@ -6,12 +6,12 @@ data "azurerm_platform_image" "example" {
} }
resource "azurerm_resource_group" "example" { resource "azurerm_resource_group" "example" {
name = "${var.name_prefix}-rg" name = "${random_pet.rg_name.id}-rg"
location = var.location location = var.location
} }
resource "azurerm_managed_disk" "example" { resource "azurerm_managed_disk" "main" {
name = "${var.name_prefix}-disk" name = "${random_pet.rg_name.id}-disk"
location = azurerm_resource_group.example.location location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name resource_group_name = azurerm_resource_group.example.name
storage_account_type = "Standard_LRS" storage_account_type = "Standard_LRS"
@ -22,3 +22,7 @@ resource "azurerm_managed_disk" "example" {
security_type = "ConfidentialVM_DiskEncryptedWithPlatformKey" security_type = "ConfidentialVM_DiskEncryptedWithPlatformKey"
} }
resource "random_pet" "rg_name" {
prefix = var.name_prefix
}

View File

@ -0,0 +1,7 @@
output "resource_group_name" {
value = azurerm_resource_group.example.name
}
output "managed_disk_name" {
value = azurerm_managed_disk.main.name
}

View File

@ -4,11 +4,11 @@ terraform {
required_providers { required_providers {
azurerm = { azurerm = {
source = "hashicorp/azurerm" source = "hashicorp/azurerm"
version = "~>3.8" version = ">= 3.0, < 4.0"
} }
} }
} }
provider "azurerm" { provider "azurerm" {
features {} features {}
} }

View File

@ -1,9 +1,11 @@
variable "location" { variable "location" {
type = string type = string
default = "westus"
description = "Location where resources will be created" description = "Location where resources will be created"
} }
variable "name_prefix" { variable "name_prefix" {
type = string type = string
default = "201-confidential-os-disk"
description = "Prefix of the resource name" description = "Prefix of the resource name"
} }