File tree Expand file tree Collapse file tree 4 files changed +59
-0
lines changed
Expand file tree Collapse file tree 4 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,7 @@ module "department_data_and_insight" {
154154 mwaa_key_arn = aws_kms_key. mwaa_key . arn
155155 user_uploads_bucket = module. user_uploads
156156 cloudtrail_bucket = module. cloudtrail_storage
157+ datahub_config_bucket = module. datahub_config
157158 additional_glue_database_access = {
158159 read_only = []
159160 read_write = [" arcus_archive" , " metastore" ]
Original file line number Diff line number Diff line change @@ -68,6 +68,16 @@ variable "cloudtrail_bucket" {
6868 default = null
6969}
7070
71+ variable "datahub_config_bucket" {
72+ description = " DataHub config S3 bucket"
73+ type = object ({
74+ bucket_id = string
75+ bucket_arn = string
76+ kms_key_arn = string
77+ })
78+ default = null
79+ }
80+
7181variable "additional_glue_database_access" {
7282 description = << EOF
7383 Additional Glue database access to grant to the department.
Original file line number Diff line number Diff line change @@ -1425,3 +1425,45 @@ resource "aws_iam_policy" "cloudtrail_access_policy" {
14251425 description = " Allows ${ local . department_identifier } department read-only access to CloudTrail bucket"
14261426 policy = data. aws_iam_policy_document . cloudtrail_access [0 ]. json
14271427}
1428+
1429+ // Write access to DataHub config bucket for Data and Insight department only
1430+ data "aws_iam_policy_document" "datahub_config_access" {
1431+ count = local. department_identifier == " data-and-insight" && var. datahub_config_bucket != null ? 1 : 0
1432+
1433+ statement {
1434+ sid = " DataHubConfigKmsAccess"
1435+ effect = " Allow"
1436+ actions = [
1437+ " kms:Encrypt" ,
1438+ " kms:Decrypt" ,
1439+ " kms:ReEncrypt*" ,
1440+ " kms:GenerateDataKey*" ,
1441+ " kms:DescribeKey"
1442+ ]
1443+ resources = [var . datahub_config_bucket . kms_key_arn ]
1444+ }
1445+
1446+ statement {
1447+ sid = " DataHubConfigS3WriteAccess"
1448+ effect = " Allow"
1449+ actions = [
1450+ " s3:GetObject" ,
1451+ " s3:GetObjectVersion" ,
1452+ " s3:ListBucket" ,
1453+ " s3:PutObject" ,
1454+ " s3:PutObjectAcl" ,
1455+ " s3:DeleteObject"
1456+ ]
1457+ resources = [
1458+ var . datahub_config_bucket . bucket_arn ,
1459+ " ${ var . datahub_config_bucket . bucket_arn } /*"
1460+ ]
1461+ }
1462+ }
1463+
1464+ resource "aws_iam_policy" "datahub_config_access_policy" {
1465+ count = local. department_identifier == " data-and-insight" && var. datahub_config_bucket != null ? 1 : 0
1466+ name = lower (" ${ var . identifier_prefix } -${ local . department_identifier } -datahub-config-access-policy" )
1467+ description = " Allows ${ local . department_identifier } department write access to DataHub config bucket"
1468+ policy = data. aws_iam_policy_document . datahub_config_access [0 ]. json
1469+ }
Original file line number Diff line number Diff line change @@ -175,3 +175,9 @@ resource "aws_iam_role_policy_attachment" "ecs_parameter_store_access" {
175175 role = aws_iam_role. department_ecs_role . name
176176 policy_arn = aws_iam_policy. parameter_store_read_only . arn
177177}
178+
179+ resource "aws_iam_role_policy_attachment" "datahub_config_access_attachment" {
180+ count = local. department_identifier == " data-and-insight" && var. datahub_config_bucket != null ? 1 : 0
181+ role = aws_iam_role. department_ecs_role . name
182+ policy_arn = aws_iam_policy. datahub_config_access_policy [0 ]. arn
183+ }
You can’t perform that action at this time.
0 commit comments