Skip to content

Commit

Permalink
feat: create separate parameters for every org_info key
Browse files Browse the repository at this point in the history
  • Loading branch information
EreminAnton committed Nov 21, 2024
1 parent 2000820 commit b0a638e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions modules/org_info/create/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ locals {
accounts = local.all_non_master_accounts
ous = local.ous_info

environment_accounts = {
accounts_by_environment = {
for prefix in ["development", "production", "staging", "security", "infrastructure"] :
prefix => compact(flatten([
for ou_key, ou in local.ous_info :
Expand Down Expand Up @@ -101,4 +101,4 @@ locals {
}
]
])
}
}
18 changes: 9 additions & 9 deletions modules/org_info/create/main.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module "naming_conventions" {
source = "fivexl/naming-conventions/aws"
version = "0.0.1"
version = "0.0.2"
}

module "shared_parameter" {
source = "../../shared_parameter"
module "shared_parameters" {
source = "../../shared_parameter"
for_each = local.org_info

parameter_name = module.naming_conventions.org_info_ssm_parameter_name
resource_share_name = module.naming_conventions.org_info_ram_resource_share_name
parameter_description = "Organization information including ARN, root ID, org ID, and account IDs"
parameter_name = module.naming_conventions.org_info_ssm_parametes_names[each.key]
resource_share_name = module.naming_conventions.org_info_ram_resource_share_names[each.key]
parameter_description = "Shared SSM parameter for ${each.key}"
parameter_key_id = var.shared_kms_key_arn
parameter_value = jsonencode(local.org_info)
parameter_value = jsonencode(each.value)
principals_to_share_with = var.principals_to_share_with

tags = var.tags
tags = var.tags
}
12 changes: 8 additions & 4 deletions modules/org_info/read/main.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
module "naming_conventions" {
source = "fivexl/naming-conventions/aws"
version = "0.0.1"
version = "0.0.2"
}

module "org_info" {
source = "../../shared_parameter_data"
source = "../../shared_parameter_data"
for_each = module.naming_conventions.org_info_ram_resource_share_names

resource_share_name = module.naming_conventions.org_info_ram_resource_share_name
resource_share_name = each.value
resource_owner = var.resource_owner
}

locals {
org_info = nonsensitive(jsondecode(module.org_info.value))
org_info = {
for key, value in module.org_info :
key => nonsensitive(jsondecode(value.value))
}
}

variable "resource_owner" {
Expand Down
4 changes: 2 additions & 2 deletions modules/org_info/read/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ output "org_id" {
description = "The ID of the organization"
}

output "environment_accounts" {
value = local.org_info.environment_accounts
output "accounts_by_environment" {
value = local.org_info.accounts_by_environment
description = "List of account IDs for each environment"
}

Expand Down

0 comments on commit b0a638e

Please sign in to comment.