AWS Serverless Application: CodePipeline notification to slack
- CodePipeline send event notification to Amazon SNS
- Invoking AWS Lambda functions via Amazon SNS
- Post to slack
- CodePipeline
- SNS Topic
- KMS
- lambda (python3.7)
$ aws sns create-topic --name codepipeline
Select events that trigger notifications, and then choose above SNS Topic as targets.
https://docs.aws.amazon.com/en_us/kms/latest/developerguide/concepts.html#customer-cmk
Encrypt slack webhook url using above CMK.
$ aws kms encrypt --key-id alias/xxx --plaintext "hooks.slack.com/services/xxx"
{
"CiphertextBlob": "xxx",
"KeyId": "arn:aws:kms:ap-northeast-1:abc:key/xxx"
}
KMS_ENCRYPTED_HOOK_URL
"CiphertextBlob"KEY_ID
"KeyId"
$ S3_BUCKET=sam-artifacts \
SNS_TOPIC_ARN=arn:aws:sns:ap-northeast-1:abc:xxx \
KEY_ID=xxx \
SLACK_CHANNEL=#channel \
KMS_ENCRYPTED_HOOK_URL=xxx \
make deploy
S3_BUCKET
s3 bucket for lambda source codeSNS_TOPIC_ARN
created sns topicKEY_ID
created a customer managed CMK key idSLACK_CHANNEL
slack channelKMS_ENCRYPTED_HOOK_URL
encrypted slack webhook url using CMK