Skip to content

Commit 018ce5e

Browse files
javsanbel2Raj Poluri
andauthored
Add clients variable which have access to all tables (#308)
* add DB sg self permissions * changelog * cahnge * space * add db * fix * fix TF formatting * remove all on dbs --------- Co-authored-by: Raj Poluri <rpoluri@expediagroup.com>
1 parent b28b4a8 commit 018ce5e

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6+
## [7.10.6] - 2025-05-02
7+
### Added
8+
- Add catalog producer roles with access to ALL Glue databases.
9+
610
## [7.10.5] - 2025-04-29
711
### Fixed
812
- Include describe permission in hive metastore lakeformation policy to fix terraform reconcilation.

lf.tf

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,27 @@ resource "aws_lakeformation_permissions" "hms_sys_loc_permissions" {
9898
}
9999

100100
locals {
101+
# Read clients
101102
catalog_client_schemas = [
102103
for pair in setproduct(local.schemas_info[*]["schema_name"], var.lf_catalog_client_arns) : {
103104
schema_name = pair[0]
104105
client_arn = pair[1]
105106
}
106107
]
108+
# Read accounts
107109
customer_account_schemas = [
108110
for pair in setproduct(local.schemas_info[*]["schema_name"], var.lf_customer_accounts) : {
109111
schema_name = pair[0]
110112
customer_account = pair[1]
111113
}
112114
]
115+
# Write producers
116+
catalog_producer_schemas = [
117+
for pair in setproduct(local.schemas_info[*]["schema_name"], var.lf_catalog_producer_arns) : {
118+
schema_name = pair[0]
119+
producer_arn = pair[1]
120+
}
121+
]
113122
}
114123

115124
resource "aws_lakeformation_permissions" "catalog_client_permissions" {
@@ -192,3 +201,57 @@ resource "aws_lakeformation_permissions" "all_principals_system_tbl_permissions"
192201
wildcard = true
193202
}
194203
}
204+
205+
# Catalog Producer permissions
206+
207+
resource "aws_lakeformation_permissions" "catalog_producer_db_permissions" {
208+
for_each = var.disable_glue_db_init && var.create_lf_resource ? tomap({
209+
for schema in local.catalog_producer_schemas : "${schema["schema_name"]}-${schema["producer_arn"]}" => schema
210+
}) : {}
211+
212+
principal = each.value.producer_arn
213+
permissions = ["DESCRIBE", "CREATE_TABLE"]
214+
215+
database {
216+
name = aws_glue_catalog_database.apiary_glue_database[each.value.schema_name].name
217+
}
218+
}
219+
220+
resource "aws_lakeformation_permissions" "catalog_producer_db_system_permissions" {
221+
for_each = var.disable_glue_db_init && var.create_lf_resource ? tomap({
222+
for schema in local.catalog_producer_schemas : "${schema["schema_name"]}-${schema["producer_arn"]}" => schema
223+
}) : {}
224+
225+
principal = each.value.producer_arn
226+
permissions = ["DESCRIBE", "CREATE_TABLE"]
227+
228+
database {
229+
name = aws_glue_catalog_database.apiary_system_glue_database[0].name
230+
}
231+
}
232+
233+
resource "aws_lakeformation_permissions" "catalog_producer_permissions" {
234+
for_each = var.disable_glue_db_init && var.create_lf_resource ? tomap({
235+
for schema in local.catalog_producer_schemas : "${schema["schema_name"]}-${schema["producer_arn"]}" => schema
236+
}) : {}
237+
238+
principal = each.value.producer_arn
239+
permissions = ["ALL", "DESCRIBE"]
240+
241+
table {
242+
database_name = aws_glue_catalog_database.apiary_glue_database[each.value.schema_name].name
243+
wildcard = true
244+
}
245+
}
246+
247+
resource "aws_lakeformation_permissions" "catalog_producer_system_permissions" {
248+
for_each = var.disable_glue_db_init && var.create_lf_resource ? toset(var.lf_catalog_producer_arns) : []
249+
250+
principal = each.key
251+
permissions = ["ALL", "DESCRIBE"]
252+
253+
table {
254+
database_name = aws_glue_catalog_database.apiary_system_glue_database[0].name
255+
wildcard = true
256+
}
257+
}

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,13 @@ variable "lf_hybrid_access_enabled" {
598598
}
599599

600600
variable "lf_catalog_client_arns" {
601-
description = "AWS IAM role ARNs granted describe permissions on all glue databases and tables using LakeFormation."
601+
description = "AWS IAM role ARNs granted DESCRIBE permissions on all glue databases and tables using LakeFormation."
602+
type = list(string)
603+
default = []
604+
}
605+
606+
variable "lf_catalog_producer_arns" {
607+
description = "AWS IAM role ARNs granted ALL permissions on all glue databases and tables using LakeFormation."
602608
type = list(string)
603609
default = []
604610
}

0 commit comments

Comments
 (0)