From 611fb91d4d318b3d1f10e18332db72cc3c2764da Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Tue, 19 Nov 2024 13:27:11 -0800 Subject: [PATCH] Initial commit --- .../101-app-configuration-store-kv/README.md | 24 +++++++++++++ .../101-app-configuration-store-kv/main.tf | 29 +++++++++++++++ .../101-app-configuration-store-kv/outputs.tf | 11 ++++++ .../providers.tf | 18 ++++++++++ .../variables.tf | 35 +++++++++++++++++++ 5 files changed, 117 insertions(+) create mode 100644 quickstart/101-app-configuration-store-kv/README.md create mode 100644 quickstart/101-app-configuration-store-kv/main.tf create mode 100644 quickstart/101-app-configuration-store-kv/outputs.tf create mode 100644 quickstart/101-app-configuration-store-kv/providers.tf create mode 100644 quickstart/101-app-configuration-store-kv/variables.tf diff --git a/quickstart/101-app-configuration-store-kv/README.md b/quickstart/101-app-configuration-store-kv/README.md new file mode 100644 index 000000000..b7ee3a102 --- /dev/null +++ b/quickstart/101-app-configuration-store-kv/README.md @@ -0,0 +1,24 @@ +# Azure App Configuration + +This template deploys an Azure App Configuration and a key-value pair. + +## Terraform resource types + +- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) +- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) +- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) +- [azurerm_app_configuration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_configuration) +- [azurerm_app_configuration_key_value](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_configuration_key_value) + +## Variables + +| Name | Description | Default value | +|-|-|-| +| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg | +| `resource_group_location` | Location of the resource group. | eastus | +| `app_configuration_name` | Name of the App Configuration resource. The value will be randomly generated if blank. | "" | +| `app_configuration_key` | Key of the App Configuration key-value pair. | "" | +| `app_configuration_label` | Label of the App Configuration key-value pair. | "" | +| `app_configuration_value` | Value of the App Configuration key-value pair. | "" | + +## Example \ No newline at end of file diff --git a/quickstart/101-app-configuration-store-kv/main.tf b/quickstart/101-app-configuration-store-kv/main.tf new file mode 100644 index 000000000..59fc8beb3 --- /dev/null +++ b/quickstart/101-app-configuration-store-kv/main.tf @@ -0,0 +1,29 @@ +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 +} + +resource "random_string" "azurerm_app_configuration_name" { + length = 13 + lower = true + numeric = false + special = false + upper = false +} + +resource "azurerm_app_configuration" "example" { + name = coalesce(var.app_configuration_name, "appcfg-${random_string.azurerm_app_configuration_name.result}") + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location +} + +resource "azurerm_app_configuration_key_value" "example" { + configuration_store_id = azurerm_app_configuration.example.id + key = var.app_configuration_key + label = var.app_configuration_label + value = var.app_configuration_value +} \ No newline at end of file diff --git a/quickstart/101-app-configuration-store-kv/outputs.tf b/quickstart/101-app-configuration-store-kv/outputs.tf new file mode 100644 index 000000000..579baaf76 --- /dev/null +++ b/quickstart/101-app-configuration-store-kv/outputs.tf @@ -0,0 +1,11 @@ +output "resource_group_name" { + value = azurerm_resource_group.rg.name +} + +output "app_configuration_name" { + value = azurerm_app_configuration.example.name +} + +output "app_configuration_key_value" { + value = azurerm_app_configuration_key_value.example.key +} \ No newline at end of file diff --git a/quickstart/101-app-configuration-store-kv/providers.tf b/quickstart/101-app-configuration-store-kv/providers.tf new file mode 100644 index 000000000..058b68717 --- /dev/null +++ b/quickstart/101-app-configuration-store-kv/providers.tf @@ -0,0 +1,18 @@ +terraform { + required_version = ">=1.0" + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~>3.0" + } + random = { + source = "hashicorp/random" + version = "~>3.0" + } + } +} + +provider "azurerm" { + features {} +} \ No newline at end of file diff --git a/quickstart/101-app-configuration-store-kv/variables.tf b/quickstart/101-app-configuration-store-kv/variables.tf new file mode 100644 index 000000000..f949335cb --- /dev/null +++ b/quickstart/101-app-configuration-store-kv/variables.tf @@ -0,0 +1,35 @@ +variable "resource_group_name_prefix" { + type = string + default = "rg" + description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription." +} + +variable "resource_group_location" { + type = string + default = "eastus" + description = "Location of the resource group." +} + +variable "app_configuration_name" { + type = string + description = "The name of the App Configuration resource. The value will be randomly generated if blank." + default = "" +} + +variable "app_configuration_key" { + type = string + description = "Key of the App Configuration key-value pair." + default = "" +} + +variable "app_configuration_label" { + type = string + description = "Label of the App Configuration key-value pair." + default = "" +} + +variable "app_configuration_value" { + type = string + description = "Value of the App Configuration key-value pair." + default = "" +} \ No newline at end of file