Skip to content

Commit a9ed726

Browse files
move common department databases to local
1 parent 8746c72 commit a9ed726

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

terraform/modules/department/50-aws-iam-policies.tf

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ locals {
1818
"glue:BatchDelete*",
1919
]
2020
}
21+
22+
common_department_databases = [
23+
aws_glue_catalog_database.raw_zone_catalog_database.name,
24+
aws_glue_catalog_database.refined_zone_catalog_database.name,
25+
aws_glue_catalog_database.trusted_zone_catalog_database.name,
26+
"unrestricted-*-zone",
27+
"${var.identifier_prefix}-raw-zone-unrestricted-addresses-api"
28+
29+
]
2130
}
2231

2332
// S3 read only access policy
@@ -195,16 +204,11 @@ data "aws_iam_policy_document" "read_only_glue_access" {
195204
"glue:SearchTables",
196205
"glue:Query*",
197206
]
198-
resources = [
199-
aws_glue_catalog_database.raw_zone_catalog_database.arn,
200-
aws_glue_catalog_database.refined_zone_catalog_database.arn,
201-
aws_glue_catalog_database.trusted_zone_catalog_database.arn,
202-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${aws_glue_catalog_database.raw_zone_catalog_database.name}/*",
203-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${aws_glue_catalog_database.refined_zone_catalog_database.name}/*",
204-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${aws_glue_catalog_database.trusted_zone_catalog_database.name}/*",
205-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:database/unrestricted-*-zone",
206-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/unrestricted-*-zone/*",
207-
]
207+
resources = flatten([
208+
["arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:catalog"],
209+
[for db in local.common_department_databases : "arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:database/${db}"],
210+
[for db in local.common_department_databases : "arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${db}/*"]
211+
])
208212
}
209213

210214
dynamic "statement" {
@@ -552,16 +556,11 @@ data "aws_iam_policy_document" "glue_access" {
552556
"glue:GetDatabases",
553557
"glue:Query*",
554558
]
555-
resources = [
556-
aws_glue_catalog_database.raw_zone_catalog_database.arn,
557-
aws_glue_catalog_database.refined_zone_catalog_database.arn,
558-
aws_glue_catalog_database.trusted_zone_catalog_database.arn,
559-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${aws_glue_catalog_database.raw_zone_catalog_database.name}/*",
560-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${aws_glue_catalog_database.refined_zone_catalog_database.name}/*",
561-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${aws_glue_catalog_database.trusted_zone_catalog_database.name}/*",
562-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:database/unrestricted-*-zone",
563-
"arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/unrestricted-*-zone/*",
564-
]
559+
resources = flatten([
560+
["arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:catalog"],
561+
[for db in local.common_department_databases : "arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:database/${db}"],
562+
[for db in local.common_department_databases : "arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${db}/*"]
563+
])
565564
}
566565

567566
dynamic "statement" {

0 commit comments

Comments
 (0)