forked from aztfmod/terraform-azurerm-caf
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic App Setting + App Config Support #7
Merged
brockneedscoffee
merged 5 commits into
cse-kratos:master
from
erikschlegel:erisch/features/dynamic_app_settings_support
Jan 22, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
39a08d6
changing the naming conventions for the cosmos module so they're more…
erikschlegel 12894ab
rebased
erikschlegel 07f9aff
rebased
erikschlegel 39575dd
initial commit for app_config
erikschlegel db3df1f
Adding new app_config module
erikschlegel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,15 @@ | ||
module app_config { | ||
source = "./modules/databases/app_config" | ||
for_each = local.database.app_config | ||
name = each.value.name | ||
|
||
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region] | ||
resource_group_name = module.resource_groups[each.value.resource_group_key].name | ||
global_settings = local.global_settings | ||
settings = each.value | ||
} | ||
|
||
output app_config { | ||
value = module.app_config | ||
sensitive = true | ||
} |
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
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
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
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
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
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
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
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,27 @@ | ||
## App Configuration | ||
|
||
resource "azurecaf_name" "app_config" { | ||
name = var.name | ||
resource_type = "azurerm_app_configuration" | ||
prefixes = [var.global_settings.prefix] | ||
random_length = var.global_settings.random_length | ||
clean_input = true | ||
passthrough = var.global_settings.passthrough | ||
use_slug = var.global_settings.use_slug | ||
} | ||
|
||
# Create config data store resource | ||
resource "azurerm_app_configuration" "config" { | ||
name = azurecaf_name.app_config.result | ||
resource_group_name = var.resource_group_name | ||
sku = try(var.settings.sku_name, "standard") | ||
location = var.location | ||
|
||
dynamic "identity" { | ||
for_each = lookup(var.settings, "identity", {}) == {} ? [] : [1] | ||
|
||
content { | ||
type = var.settings.identity.type | ||
} | ||
} | ||
} |
File renamed without changes.
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,14 @@ | ||
output id { | ||
value = azurerm_app_configuration.config.id | ||
description = "The ID of the App Config." | ||
} | ||
|
||
output endpoint { | ||
value = azurerm_app_configuration.config.endpoint | ||
description = "The URL of the App Configuration." | ||
} | ||
|
||
output identity { | ||
value = azurerm_app_configuration.config.identity | ||
description = "The managed service identity object." | ||
} |
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,16 @@ | ||
variable settings {} | ||
variable global_settings { | ||
description = "Global settings object (see module README.md)" | ||
} | ||
variable resource_group_name { | ||
description = "(Required) The name of the resource group where to create the resource." | ||
type = string | ||
} | ||
variable location { | ||
description = "(Required) Specifies the supported Azure location where to create the resource. Changing this forces a new resource to be created." | ||
type = string | ||
} | ||
|
||
variable name { | ||
description = "(Required) Name of the App Config" | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,9 @@ | ||
output cosmos_account { | ||
value = azurerm_cosmosdb_account.cosmos_account.id | ||
sensitive = true | ||
} | ||
|
||
output connection_string { | ||
value = azurerm_cosmosdb_account.cosmos_account.connection_strings[0] | ||
sensitive = true | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,14 @@ | ||
locals { | ||
module_tag = { | ||
"module" = basename(abspath(path.module)) | ||
} | ||
#tags = merge(local.module_tag, try(var.settings.tags, null), var.base_tags) | ||
} | ||
|
||
terraform { | ||
required_providers { | ||
azurecaf = { | ||
source = "aztfmod/azurecaf" | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,27 @@ | ||
locals { | ||
# Expected Variable: dynamic_app_settings = { | ||
# "KEYVAULT_URL" = { | ||
# keyvaults = { | ||
# my_common_vault = { | ||
# lz_key = "common_services_lz" | ||
# attribute_key = "vault_uri" | ||
# } | ||
# } | ||
# } | ||
# } | ||
dynamic_settings_to_process = { | ||
for setting in | ||
flatten( | ||
[ | ||
for setting_name, resources in var.dynamic_app_settings : [ | ||
for resource_type_key, resource in resources : [ | ||
for object_id_key, object_attributes in resource : { | ||
key = setting_name | ||
value = try(var.combined_objects[resource_type_key][object_attributes.lz_key][object_id_key][object_attributes.attribute_key], var.combined_objects[resource_type_key][var.client_config.landingzone_key][object_id_key][object_attributes.attribute_key]) | ||
} | ||
] | ||
] | ||
] | ||
) : setting.key => setting.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
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
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
27 changes: 27 additions & 0 deletions
27
modules/webapps/function_app/locals.dynamic_app_settings.tf
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,27 @@ | ||
locals { | ||
# Expected Variable: dynamic_app_settings = { | ||
# "KEYVAULT_URL" = { | ||
# keyvaults = { | ||
# my_common_vault = { | ||
# lz_key = "common_services_lz" | ||
# attribute_key = "vault_uri" | ||
# } | ||
# } | ||
# } | ||
# } | ||
dynamic_settings_to_process = { | ||
for setting in | ||
flatten( | ||
[ | ||
for setting_name, resources in var.dynamic_app_settings : [ | ||
for resource_type_key, resource in resources : [ | ||
for object_id_key, object_attributes in resource : { | ||
key = setting_name | ||
value = try(var.combined_objects[resource_type_key][object_attributes.lz_key][object_id_key][object_attributes.attribute_key], var.combined_objects[resource_type_key][var.client_config.landingzone_key][object_id_key][object_attributes.attribute_key]) | ||
} | ||
] | ||
] | ||
] | ||
) : setting.key => setting.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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erikschlegel given the CAF team's guidance on this flag do we still want to move forward with it? They have taken it out of the core modules but use it in the landing zone itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes me really nervous getting rid of the sensitive flag given the cosmos connection string would be exposed in clear text within the state file. Removing this flag seemed like a band aid fix due to upgrading to the latest version of Terraform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, just wanted to verify