Skip to content
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

Update_181124_1 #8695

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions terraform/environments/ppud/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ resource "aws_iam_role_policy_attachment" "attach_lambda_policy_certificate_expi

## Production

/*
data "aws_iam_policy_document" "sns_topic_policy_ec2cw" {
count = local.is-production == true ? 1 : 0
policy_id = "SnsTopicId"
Expand Down Expand Up @@ -895,6 +896,7 @@ data "aws_iam_policy_document" "sns_topic_policy_ec2cw" {
]
}
}
*/

####################################################
# IAM User, Policy for MGN
Expand Down
38 changes: 37 additions & 1 deletion terraform/environments/ppud/sns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ resource "aws_sns_topic" "cw_alerts" {
name = "ppud-prod-cw-alerts"
}

/*
resource "aws_sns_topic_policy" "sns_policy" {
count = local.is-production == true ? 1 : 0
arn = aws_sns_topic.cw_alerts[0].arn
policy = data.aws_iam_policy_document.sns_topic_policy_ec2cw[0].json
policy = data.aws_iam_policy_document.sns_topic_policy_ec2cw[0].json
}
*/

resource "aws_sns_topic_subscription" "cw_subscription" {
count = local.is-production == true ? 1 : 0
topic_arn = aws_sns_topic.cw_alerts[0].arn
Expand Down Expand Up @@ -62,6 +65,39 @@ resource "aws_sns_topic_subscription" "cw_sms_subscription4" {
}
*/

resource "aws_sns_topic_policy" "sns_topic_policy_ec2cw" {
count = local.is-production == true ? 1 : 0
arn = aws_sns_topic.cw_alerts[0].arn

policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
"Sid" : "SnsTopicId",
"Effect" : "Allow",
"Principal" : {
"AWS" : "*"
},
"Action" : [
"SNS:Publish",
"SNS:RemovePermission",
"SNS:SetTopicAttributes",
"SNS:DeleteTopic",
"SNS:ListSubscriptionsByTopic",
"SNS:GetTopicAttributes",
"SNS:AddPermission",
"SNS:Subscribe"
],
"Resource" : "aws_sns_topic.cw_alerts[0].arn",
"Condition" : {
"StringEquals" : {
"AWS:SourceOwner" : "data.aws_caller_identity.current.account_id"
}
}
}
]
})
}

# PreProduction - Cloud Watch

Expand Down
Loading