Skip to content

Commit d6c4cea

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

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ 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+
]
2129
}
2230

2331
// S3 read only access policy
@@ -195,16 +203,11 @@ data "aws_iam_policy_document" "read_only_glue_access" {
195203
"glue:SearchTables",
196204
"glue:Query*",
197205
]
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-
]
206+
resources = flatten([
207+
["arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:catalog"],
208+
[for db in local.common_department_databases : "arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:database/${db}"],
209+
[for db in local.common_department_databases : "arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${db}/*"]
210+
])
208211
}
209212

210213
dynamic "statement" {
@@ -552,16 +555,11 @@ data "aws_iam_policy_document" "glue_access" {
552555
"glue:GetDatabases",
553556
"glue:Query*",
554557
]
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-
]
558+
resources = flatten([
559+
["arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:catalog"],
560+
[for db in local.common_department_databases : "arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:database/${db}"],
561+
[for db in local.common_department_databases : "arn:aws:glue:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${db}/*"]
562+
])
565563
}
566564

567565
dynamic "statement" {

0 commit comments

Comments
 (0)