diff --git a/services/terraform/modules/shared/outputs.tf b/services/terraform/modules/shared/outputs.tf new file mode 100644 --- /dev/null +++ b/services/terraform/modules/shared/outputs.tf @@ -0,0 +1,13 @@ +locals { + exported_dynamodb_tables = [ + aws_dynamodb_table.feature-flags + ] +} + +# map table names to their resources +output "dynamodb_tables" { + value = { + for table in local.exported_dynamodb_tables : + table.name => table + } +} diff --git a/services/terraform/remote/aws_iam.tf b/services/terraform/remote/aws_iam.tf --- a/services/terraform/remote/aws_iam.tf +++ b/services/terraform/remote/aws_iam.tf @@ -108,9 +108,6 @@ } # Feature Flags IAM -data "aws_dynamodb_table" "feature_flags" { - name = "feature-flags" -} data "aws_iam_policy_document" "read_feature_flags" { statement { sid = "FeatureFlagsDDBReadAccess" @@ -122,7 +119,7 @@ "dynamodb:Scan", ] resources = [ - data.aws_dynamodb_table.feature_flags.arn, + module.shared.dynamodb_tables["feature-flags"].arn ] } }