2

I created a Lambda function that will publish a message to a slack channel and I have it triggered by an SNS topic. Can I use the SNS subscription filter policy to pass data to my Lambda function so it can be read and used in the Lambda function? I assume Lambda could read the parameters passed from SNS in the Lambda with using event?

event['message']

I just don't want to create a Lambda function for each trigger I will create. I want to have one Lambda function, pass in the custom text from separate SNS topics therefore making the function reusable.

I have one SNS topic for CodeDeploy passing and one for it failing. I want to just pass in the message "CodeDeploy passed" or "CodeDepoy failed" into the Lambda function.

Thanks for any help or advice!!

1 Answer 1

2

You should trigger your Lambda function with CloudWatch Events with Event Patterns. This way you can specify the event that your Lambda function will receive (constant or parts of the source event).

Here is an example for a 'SUCCESS' with CodeDeploy: enter image description here

You can achieve what you want using a single rule matching both 'SUCCESS' and 'FAILURE' and a logic in your Lambda function based on the source event or part of it to create a Slack message.

Sign up to request clarification or add additional context in comments.

1 Comment

That is what I wound up doing - creating a rule in Cloudwatch. I used this to monitor my code pipeline. I have this in my Event source - The I learned to use the 'event' as the variable that held the message in the Lambda event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.