-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Give SNS feedback access to CloudWatch #237
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,23 @@ data "aws_iam_policy_document" "sns_feedback" { | |
} | ||
} | ||
|
||
// See https://repost.aws/knowledge-center/monitor-sns-texts-cloudwatch for required permissions to deliver status logs | ||
data "aws_iam_policy_document" "sns_feedback_allow_delivery_status_logs" { | ||
count = local.create_sns_feedback_role ? 1 : 0 | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = [ | ||
"logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents", | ||
"logs:PutMetricFilter", | ||
"logs:PutRetentionPolicy", | ||
] | ||
resources = ["*"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we know the ARN and can scope it with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that is the log group for Lambda logs, which is not what we want here. We instead need the SNS feedback log groups, per my other comment. I could restrict it down to |
||
} | ||
} | ||
|
||
resource "aws_iam_role" "sns_feedback_role" { | ||
count = local.create_sns_feedback_role ? 1 : 0 | ||
|
||
|
@@ -36,3 +53,11 @@ resource "aws_iam_role" "sns_feedback_role" { | |
var.sns_topic_feedback_role_tags, | ||
) | ||
} | ||
|
||
resource "aws_iam_role_policy" "sns_feedback_role" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create a policy and attach it instead of inline policy. name should not be hardcoded - you can see other modules for references There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, can do! Is this what you are referring to? https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/573f574c922782bc658f05523d0c902a4792b0a8/vpc-flow-logs.tf#L115-L129 Would you like me to add a _policy_name and _policy_use_name_prefix variable for this? |
||
count = local.create_sns_feedback_role ? 1 : 0 | ||
|
||
role = aws_iam_role.sns_feedback_role[0].name | ||
name = "allow-delivery-status-logs" | ||
policy = data.aws_iam_policy_document.sns_feedback_allow_delivery_status_logs[0].json | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terraform creates the log group, this one can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are the 2 SNS log groups being created? I see a log group for Lambda logs, but that is different. I believe this permission is necessary for the
sns/:region/:account/:topic
andsns/:region/:account/:topic/Failure
log groups that are auto-created by SNS (assuming permissions are wired up correctly)