Skip to content

Repository files navigation

checkpoint

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.

Usage

Prerequisites:

  1. Install and configure AWS CLI.

  2. Create Slack app.

  3. Add the following scopes for bot token OAuth.

channels:read
chat:write
chat:write.customize
  1. Install and authorize the app for the workspace.

  2. Add a manual approval action in the Codepipeline. Set a timeout in the manual approval step.

  3. Create S3 bucket to store the packaged code used in deployment of Lambda functions.

Template Deployment:

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.

Available Parameters

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: CommaDelimitedListDescription: 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: StringDescription: Channel ID of the Slack channel.ProjectName:
Type: StringDescription: Project name or app name.SlackOAuthToken:
Type: StringDescription: OAuth token for API request to Slack.SlackVerificationToken:
Type: StringDescription: Verification Token for Approval Handler FunctionSnsTopicName:
Type: StringDescription: SNS topic name.TableName:
Type: StringDescription: Table name to be created in DynamoDB.

License

See the LICENSE file.

Notes

From the team at QRStuff with ❤️ for automation with Cloudformation.

About

Lambdas & CloudFormation template for sending CodePipeline approval actions to Slack.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages