This project provides an AWS Lambda based on this blueprint that captures a Cloudwatch alarm via SNS and publishes an alert to a Slack channel.
- This project is tested against Python 3.7+ in CircleCI.
git clone git@github.com:GovWizely/lambda-errors.git
cd lambda-errors
mkvirtualenv -p /usr/local/bin/python3.8 -r requirements-test.txt errors
If you are using PyCharm, make sure you enable code compatibility inspections for Python 3.7/3.8.
python -m pytest- Define the Slack hook URL and channel as environment variables e.g.
export hookUrl=hooks.slack.com/services/abc. This will allow you to run the Lambda locally. - Define AWS credentials in either
config.yamlor in the [default] section of~/.aws/credentials. To use another profile, you can do something likeexport AWS_DEFAULT_PROFILE=govwizely. - Edit
config.yamlif you want to specify a different AWS region, role, and so on. - Make sure you do not commit the AWS credentials to version control.
lambda invoke -v
To deploy:
lambda deploy --requirements requirements.txt