From dd30e9384e0b9826082fea174e44cb872d77bd59 Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Tue, 7 Feb 2023 18:37:41 -0800 Subject: [PATCH] Uploaded updated sample for HashiCorp article (#135) --- .../README.md | 2 + .../index.html | 1 + .../main.tf | 44 +++++++++++++++++++ .../output.tf | 7 +++ .../providers.tf | 19 ++++++++ .../variables.tf | 9 ++++ 6 files changed, 82 insertions(+) create mode 100644 quickstart/101-storage-account-with-static-website/README.md create mode 100644 quickstart/101-storage-account-with-static-website/index.html create mode 100644 quickstart/101-storage-account-with-static-website/main.tf create mode 100644 quickstart/101-storage-account-with-static-website/output.tf create mode 100644 quickstart/101-storage-account-with-static-website/providers.tf create mode 100644 quickstart/101-storage-account-with-static-website/variables.tf diff --git a/quickstart/101-storage-account-with-static-website/README.md b/quickstart/101-storage-account-with-static-website/README.md new file mode 100644 index 00000000..27f24949 --- /dev/null +++ b/quickstart/101-storage-account-with-static-website/README.md @@ -0,0 +1,2 @@ +# build_local_module +A module to deploy basic Azure resources diff --git a/quickstart/101-storage-account-with-static-website/index.html b/quickstart/101-storage-account-with-static-website/index.html new file mode 100644 index 00000000..8d1eb53f --- /dev/null +++ b/quickstart/101-storage-account-with-static-website/index.html @@ -0,0 +1 @@ +

This is a static website example

\ No newline at end of file diff --git a/quickstart/101-storage-account-with-static-website/main.tf b/quickstart/101-storage-account-with-static-website/main.tf new file mode 100644 index 00000000..151eef4d --- /dev/null +++ b/quickstart/101-storage-account-with-static-website/main.tf @@ -0,0 +1,44 @@ +data "azurerm_client_config" "current" {} + +# Generate random resource group name +resource "random_pet" "rg_name" { + prefix = var.resource_group_name_prefix +} + +resource "azurerm_resource_group" "rg" { + location = var.resource_group_location + name = random_pet.rg_name.id +} + +# Generate random value for the storage account name +resource "random_string" "storage_account_name" { + length = 8 + lower = true + numeric = false + special = false + upper = false +} + +resource "azurerm_storage_account" "storage_account" { + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + + name = random_string.storage_account_name.result + + account_tier = "Standard" + account_replication_type = "LRS" + account_kind = "StorageV2" + + static_website { + index_document = "index.html" + } +} + +resource "azurerm_storage_blob" "example" { + name = "index.html" + storage_account_name = azurerm_storage_account.storage_account.name + storage_container_name = "$web" + type = "Block" + content_type = "text/html" + source = "index.html" +} diff --git a/quickstart/101-storage-account-with-static-website/output.tf b/quickstart/101-storage-account-with-static-website/output.tf new file mode 100644 index 00000000..8cb21de7 --- /dev/null +++ b/quickstart/101-storage-account-with-static-website/output.tf @@ -0,0 +1,7 @@ +output "resource_group_name" { + value = azurerm_resource_group.rg.name +} + +output "storage_account_name" { + value = azurerm_storage_account.storage_account.name +} diff --git a/quickstart/101-storage-account-with-static-website/providers.tf b/quickstart/101-storage-account-with-static-website/providers.tf new file mode 100644 index 00000000..0d51fc35 --- /dev/null +++ b/quickstart/101-storage-account-with-static-website/providers.tf @@ -0,0 +1,19 @@ +terraform { + required_version = ">=1.0" + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~>3.0" + } + + random = { + source = "hashicorp/random" + version = "~>3.0" + } + } +} + +provider "azurerm" { + features {} +} diff --git a/quickstart/101-storage-account-with-static-website/variables.tf b/quickstart/101-storage-account-with-static-website/variables.tf new file mode 100644 index 00000000..d99bf4b8 --- /dev/null +++ b/quickstart/101-storage-account-with-static-website/variables.tf @@ -0,0 +1,9 @@ +variable "resource_group_location" { + default = "eastus" + description = "Location of the resource group." +} + +variable "resource_group_name_prefix" { + default = "rg" + description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription." +}