CloudFormation template for creating the AWS components for Slack notification for CodePipeline Manual Approval Actions.
It also contains a lambda handler function to update the slack message according to the received approval/denial event from slack, console or codepipeline timeout source.
channels:read
chat:write
chat:write.customize
-
Install and authorize the app for the workspace.
-
Add a manual approval action in the Codepipeline. Set a timeout in the manual approval step.
-
Create S3 bucket to store the packaged code used in deployment of Lambda functions.
The cloudformation template can be deployed directly using cli. Two steps are required: packaging the template to upload the lambda function code and creating the stack.
aws cloudformation package --template-file ./template.yml --s3-bucket checkpointest --output-template-file out.yml
aws cloudformation create-stack --stack-name <stack-name> --template-body file://out.yml \
--parameters \
ParameterKey=ProjectName,ParameterValue=<stack-name> \
ParameterKey=SlackVerificationToken,ParameterValue=<slack-verification-token> \
ParameterKey=SlackOAuthToken,ParameterValue=<slack-bot-oauth-token> \
ParameterKey=ChannelId,ParameterValue=<slack-channel-id> \
--capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND
After completion of stack deployment, edit the Manual Approval Step in pipeline. In the field SNS topic ARN - optional, select the SNS topic Approval-Notification, save the pipeline and Release Changes.
Following parameters are available for customization. Defaults can be set in the template, and can be overridden via cli as mentioned in the Template Deployment.
ApprovalStepArn:
Type: CommaDelimitedList
Description: Arn for the manual approval for IAM policy, e.g., format (arn:aws:codepipeline:region:aws-account-id:pipeline-name/stage-name/action-name).
ChannelId:
Type: String
Description: Channel ID of the Slack channel.
ProjectName:
Type: String
Description: Project name or app name.
SlackOAuthToken:
Type: String
Description: OAuth token for API request to Slack.
SlackVerificationToken:
Type: String
Description: Verification Token for Approval Handler Function
SnsTopicName:
Type: String
Description: SNS topic name.
TableName:
Type: String
Description: Table name to be created in DynamoDB.
See the LICENSE file.
From the team at QRStuff with ❤️ for automation with Cloudformation.