Skip to content

Commit 5335397

Browse files
ryanbrattenb-dalton
andauthored
Allow keys to access all resources in service as per AWS docs (#787)
* Allow keys to access all resources in service as per AWS docs * Re-add kms decrypt permissions on lambdas Co-authored-by: b-dalton <[email protected]>
1 parent d1d0602 commit 5335397

File tree

7 files changed

+253
-257
lines changed

7 files changed

+253
-257
lines changed

terraform/core/05-departments.tf

Lines changed: 226 additions & 238 deletions
Large diffs are not rendered by default.

terraform/core/28-glue-error-notifications.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ data "aws_iam_policy_document" "glue_failure_notification_lambda" {
101101
"arn:aws:sns:*:*:glue-failure-notification-*"
102102
]
103103
}
104+
105+
statement {
106+
actions = [
107+
"kms:GenerateDataKey*",
108+
"kms:Decrypt"
109+
]
110+
effect = "Allow"
111+
resources = ["*"]
112+
}
104113
}
105114

106115
resource "aws_iam_policy" "glue_failure_notification_lambda" {
@@ -193,9 +202,7 @@ data "aws_iam_policy_document" "admin_failure_notifications_kms_key_policy" {
193202
type = "Service"
194203
}
195204

196-
resources = [
197-
aws_lambda_function.glue_failure_notification_lambda.arn
198-
]
205+
resources = ["*"]
199206
}
200207
}
201208

terraform/modules/db-snapshot-to-s3/20-rds-to-s3-lambda.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ data "aws_iam_policy_document" "rds_snapshot_to_s3_lambda" {
107107
effect = "Allow"
108108
resources = [
109109
aws_kms_key.s3_to_s3_copier_kms_key.arn,
110+
aws_kms_key.rds_snapshot_to_s3_kms_key.arn
110111
]
111112
}
112113
}

terraform/modules/db-snapshot-to-s3/25-rds-to-s3-queue.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ data "aws_iam_policy_document" "rds_snapshot_to_s3_kms_key_policy" {
5757
type = "Service"
5858
}
5959

60-
resources = [
61-
data.aws_sns_topic.rds_snapshot_to_s3.arn
62-
]
60+
resources = ["*"]
6361
}
6462

6563
statement {
@@ -73,7 +71,7 @@ data "aws_iam_policy_document" "rds_snapshot_to_s3_kms_key_policy" {
7371
type = "Service"
7472
}
7573

76-
resources = [for item in var.rds_instance_ids : "arn:aws:rds:eu-west-2:${data.aws_caller_identity.current.account_id}:db:${item}"]
74+
resources = ["*"]
7775
}
7876

7977
statement {
@@ -87,9 +85,7 @@ data "aws_iam_policy_document" "rds_snapshot_to_s3_kms_key_policy" {
8785
type = "Service"
8886
}
8987

90-
resources = [
91-
aws_lambda_function.rds_snapshot_to_s3_lambda.arn
92-
]
88+
resources = ["*"]
9389
}
9490
}
9591

terraform/modules/db-snapshot-to-s3/45-s3-to-s3-copier-queue.tf

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ data "aws_iam_policy_document" "s3_to_s3_copier_kms_key_policy" {
5252
type = "Service"
5353
}
5454

55-
resources = [
56-
aws_lambda_function.s3_to_s3_copier_lambda.arn
57-
]
55+
resources = ["*"]
5856
}
5957
}
6058

@@ -74,6 +72,17 @@ data "aws_iam_policy_document" "s3_to_s3_copier" {
7472
aws_sqs_queue.s3_to_s3_copier.arn
7573
]
7674
}
75+
76+
statement {
77+
actions = [
78+
"kms:GenerateDataKey*",
79+
"kms:Decrypt"
80+
]
81+
effect = "Allow"
82+
resources = [
83+
aws_kms_key.s3_to_s3_copier_kms_key.arn,
84+
]
85+
}
7786
}
7887

7988
resource "aws_sqs_queue_policy" "s3_copier_to_s3" {

terraform/modules/department/01-inputs-required.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,4 @@ variable "redshift_ip_addresses" {
131131
variable "redshift_port" {
132132
description = "Port that the redshift cluster is running on"
133133
type = number
134-
}
135-
136-
variable "glue_failure_notification_lambda_arn" {
137-
description = "Arn of the lambda that will publish to the glue failure notification sns topic"
138-
type = string
139134
}

terraform/modules/department/70-aws-sns.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ data "aws_iam_policy_document" "glue_jobs_kms_key_policy" {
4141
type = "Service"
4242
}
4343

44-
resources = [var.glue_failure_notification_lambda_arn]
44+
resources = ["*"]
4545
}
4646
}
4747

0 commit comments

Comments
 (0)