Skip to content

Commit

Permalink
feat: improve the Athena and Glue metadata read policies (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardolsmendes authored Mar 7, 2024
1 parent cc53f4f commit dfd45f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
24 changes: 19 additions & 5 deletions infrastructure/modules/athena/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,44 @@ data "aws_iam_policy_document" "athena_query_results_management" {
}
}

data "aws_iam_policy_document" "silver_layer_access" {
data "aws_iam_policy_document" "athena_metadata_read_access" {
statement {
effect = "Allow"
actions = [
"athena:ListDataCatalogs"
]
resources = [
"*"
]
}
}

data "aws_iam_policy_document" "glue_catalog_read_access" {
statement {
effect = "Allow"
actions = [
"glue:GetDatabase",
"glue:GetDatabases"
"glue:GetDatabases",
"glue:GetTable",
"glue:GetTables"
]
resources = [
"${local.glue_resource_arn_prefix}:catalog",
"${local.glue_resource_arn_prefix}:database/*"
]
}
}

data "aws_iam_policy_document" "silver_tables_read_access" {
statement {
effect = "Allow"
actions = [
"glue:GetDatabase",
"glue:GetTable",
"glue:GetTables",
"glue:GetPartition",
"glue:GetPartitions"
]
resources = [
"${local.glue_resource_arn_prefix}:catalog",
"${local.glue_resource_arn_prefix}:database/${var.silver_database_name}",
"${local.glue_resource_arn_prefix}:table/${var.silver_database_name}/*"
]
}
Expand Down
6 changes: 3 additions & 3 deletions infrastructure/modules/athena/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ resource "aws_iam_policy" "athena_query_results_management" {
policy = data.aws_iam_policy_document.athena_query_results_management.json
}

resource "aws_iam_policy" "silver_layer_access" {
resource "aws_iam_policy" "silver_tables_read_access" {
name = "GlueCICDSilverLayerAccessPolicy-${var.environment}"
description = "Grants access to the assets that belong to the Silver layer."
policy = data.aws_iam_policy_document.silver_layer_access.json
description = "Grants read access to the tables that belong to the Silver layer."
policy = data.aws_iam_policy_document.silver_tables_read_access.json
}

0 comments on commit dfd45f1

Please sign in to comment.