-
Notifications
You must be signed in to change notification settings - Fork 826
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0243bf3
commit 611fb91
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "" | ||
} |