Skip to content

DPC-4713: SNS To Slack lambda#259

Merged
jdettmannnava merged 24 commits intomainfrom
jd/dpc-4713-sns-to-slack-lambda
Jul 15, 2025
Merged

DPC-4713: SNS To Slack lambda#259
jdettmannnava merged 24 commits intomainfrom
jd/dpc-4713-sns-to-slack-lambda

Conversation

@jdettmannnava
Copy link
Contributor

@jdettmannnava jdettmannnava commented Jun 30, 2025

🎫 Ticket

https://jira.cms.gov/browse/DPC-4713

🛠 Changes

Added lambda triggered by SNS message from CloudWatch alarm. Includes deploy workflow and the executable code.

ℹ️ Context

DPC is no longer allowed to use ChatBot to send messages to dpc-alerts from AWS, so we are following a recommendation to have alerts trigger a lambda that sends them to a slack webhook.

The infrastructure still builds S3 buckets, although this is not used for actual deployment.

🧪 Validation

Workflow which tests code and terraform passes.
Deployed to dev manually and triggered manually and it worked.

Samples:
Example Messages

@jdettmannnava jdettmannnava marked this pull request as ready for review July 3, 2025 17:30
@jdettmannnava jdettmannnava requested a review from a team as a code owner July 3, 2025 17:30
Copy link
Member

@gsf gsf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we bring the lambda code itself into the alarm-to-slack directory? This is a great start and I think it could be turned into a general lambda, one per account, that listens for cloudwatch alarms for all teams and sends them on to the relevant channels.

}

variable "env" {
description = "The application environment (dev, test, sandbox,prod)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a space before prod here.

jscott-nava
jscott-nava previously approved these changes Jul 8, 2025
@jdettmannnava jdettmannnava requested review from a team July 11, 2025 15:42
@jdettmannnava jdettmannnava requested review from gsf and jscott-nava July 14, 2025 16:03
MEspositoE14s
MEspositoE14s previously approved these changes Jul 14, 2025
Copy link

@MEspositoE14s MEspositoE14s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Does this mean I have to finally learn Python now?

tags = {
application = var.app
business = "oeda"
code = "https://github.com/CMSgov/ab2d-bcda-dpc-platform/tree/main/terraform/services/alarm-to-slack"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well make this CMSgov/cdap now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it should just be pointing to itself, since it is in the same repo!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, nm...

MEspositoE14s
MEspositoE14s previously approved these changes Jul 14, 2025
Copy link
Member

@gsf gsf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lambda zipping can be done in terraform with an archive_file data source and a filename attribute in the aws_lambda_function resource, but it would involve extending the function module. That can be left for a future PR.

As discussed in Slack, this could also be updated in the future to accept multiple SNS topics and route accordingly, allowing for a single lambda in each account to handle all alarms going to Slack.

@@ -0,0 +1 @@
__pycache__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be added to the top-level .gitignore.

@jdettmannnava jdettmannnava merged commit 29e8a79 into main Jul 15, 2025
6 checks passed
@jdettmannnava jdettmannnava deleted the jd/dpc-4713-sns-to-slack-lambda branch July 15, 2025 17:29
juliareynolds-nava pushed a commit that referenced this pull request Jul 28, 2025
## 🎫 Ticket

https://jira.cms.gov/browse/DPC-4713

## 🛠 Changes

Added lambda triggered by SNS message from CloudWatch alarm. Includes
deploy workflow and the executable code.

## ℹ️ Context

DPC is no longer allowed to use ChatBot to send messages to dpc-alerts
from AWS, so we are following a recommendation to have alerts trigger a
lambda that sends them to a slack webhook.

The infrastructure still builds S3 buckets, although this is not used
for actual deployment.

## 🧪 Validation

Workflow which tests code and terraform passes.
Deployed to dev manually and triggered manually and it worked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants