Skip to content

Commit 63b3ebf

Browse files
authored
fix: ensuring the account names are ordered (#54)
1 parent a38c5b1 commit 63b3ebf

File tree

5 files changed

+107
-12
lines changed

5 files changed

+107
-12
lines changed

main.tf

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,23 @@ resource "aws_sns_topic_subscription" "subscribers" {
4444
module "notify" {
4545
source = "./modules/notify"
4646

47+
accounts_id_to_name = var.accounts_id_to_name
4748
cloudwatch_log_group_kms_key_id = var.cloudwatch_log_group_kms_key_id
4849
cloudwatch_log_group_retention_in_days = var.cloudwatch_log_group_retention
4950
cloudwatch_log_group_tags = var.tags
5051
create_sns_topic = false
52+
delivery_channels = local.channels_config
53+
enable_slack = var.enable_slack
54+
enable_teams = var.enable_teams
5155
iam_role_tags = var.tags
56+
identity_center_role = var.identity_center_role
57+
identity_center_start_url = var.identity_center_start_url
5258
lambda_function_tags = var.tags
59+
post_icons_url = var.post_icons_url
5360
recreate_missing_package = false
54-
enable_slack = var.enable_slack
55-
enable_teams = var.enable_teams
56-
delivery_channels = local.channels_config
5761
sns_topic_name = var.sns_topic_name
5862
sns_topic_tags = var.tags
5963
tags = var.tags
6064

61-
accounts_id_to_name = var.accounts_id_to_name
62-
post_icons_url = var.post_icons_url
63-
64-
identity_center_start_url = var.identity_center_start_url
65-
identity_center_role = var.identity_center_role
66-
6765
depends_on = [module.sns]
6866
}

modules/notify/.terraform.lock.hcl

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/notify/main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ locals {
6363
}
6464
}
6565

66+
## We need to ensure the account names are ordered
67+
account_by_ids = [
68+
for name in sort(keys(var.accounts_id_to_name)) : {
69+
id = name
70+
name = var.accounts_id_to_name[name]
71+
}
72+
]
73+
6674
accounts_id_to_name_python_dictonary = templatefile(
6775
"${path.module}/mapAccountIdToName-python-dict.tftpl",
6876
{
69-
accounts_id_to_name = var.accounts_id_to_name
77+
accounts_id_to_name = local.account_by_ids
7078
}
7179
)
7280
notification_emblems_python = templatefile(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by terraform
22
ACCOUNT_ID_TO_NAME = {
3-
%{~ for account_id, account_name in accounts_id_to_name}
4-
"${account_id}": "${account_name}",
3+
%{~ for account in accounts_id_to_name}
4+
"${account.id}": "${account.name}",
55
%{~ endfor}
66
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ terraform {
66
source = "hashicorp/aws"
77
version = ">= 4.8"
88
}
9+
local = {
10+
source = "hashicorp/local"
11+
version = ">= 2.5.0"
12+
}
913
}
1014
}

0 commit comments

Comments
 (0)