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

Creating SNS topics and updating IAM policy for instance scheduler #5679

Merged
merged 1 commit into from
Dec 5, 2023
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
11 changes: 11 additions & 0 deletions terraform/environments/core-shared-services/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ data "aws_iam_policy_document" "instance-scheduler-lambda-function-policy" {
resources = ["*"]
actions = ["kms:Decrypt"]
}
statement {
sid = "AllowLambdaToPublishToSNSTopics"
effect = "Allow"
actions = [
"sns:Publish"
]
resources = [
aws_sns_topic.on_success.arn,
aws_sns_topic.on_failure.arn
]
}
}

## END: IAM for Instance Scheduler Lambda Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,22 @@ resource "aws_cloudwatch_event_target" "instance_scheduler_weekly_start_in_the_m
}

## END: Start trigger for Instance Scheduler Lambda Function

# sns topics that are the instance scheduler lambda function's destination configuration
resource "aws_sns_topic" "on_failure" {
name = "instance-scheduler-event-notification-topic-on-failure"
}

resource "aws_sns_topic" "on_success" {
name = "instance-scheduler-event-notification-topic-on-success"
}

# link the sns topics to the pagerduty service
module "pagerduty_core_alerts" {
depends_on = [
aws_sns_topic.on_failure, aws_sns_topic.on_success
]
source = "github.com/ministryofjustice/modernisation-platform-terraform-pagerduty-integration?ref=v2.0.0"
sns_topics = [aws_sns_topic.on_failure.name, aws_sns_topic.on_success.name]
pagerduty_integration_key = local.pagerduty_integration_keys["operations_cloudwatch"]
}
Loading