Cdk component that provisions a #slack approval workflow and notification messages on codepipeline state changes
Project description
@cloudcomponents/cdk-codepipeline-slack
Cdk component that provisions a #slack approval workflow and notification messages on codepipeline state changes
Install
TypeScript/JavaScript:
npm install --save @cloudcomponents/cdk-codepipeline-slack
Python:
pip install cloudcomponents.cdk-codepipeline-slack
How to use
import { Construct, Stack, StackProps } from '@aws-cdk/core';
import { Repository } from '@aws-cdk/aws-codecommit';
import { Pipeline, Artifact } from '@aws-cdk/aws-codepipeline';
import {
CodeCommitSourceAction,
CodeBuildAction,
} from '@aws-cdk/aws-codepipeline-actions';
import { PipelineProject } from '@aws-cdk/aws-codebuild';
import {
SlackApprovalAction,
SlackNotifier,
} from '@cloudcomponents/cdk-codepipeline-slack';
export class CodePipelineSlackApprovalStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const repository = new Repository(this, 'Repository', {
repositoryName: 'MyRepositoryName',
});
const sourceArtifact = new Artifact();
const sourceAction = new CodeCommitSourceAction({
actionName: 'CodeCommit',
repository,
output: sourceArtifact,
});
const project = new PipelineProject(this, 'MyProject');
const buildAction = new CodeBuildAction({
actionName: 'CodeBuild',
project,
input: sourceArtifact,
});
const slackBotToken = process.env.SLACK_BOT_TOKEN as string;
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET as string;
const slackChannel = process.env.SLACK_CHANNEL_NAME as string;
const approvalAction = new SlackApprovalAction({
actionName: 'SlackApproval',
slackBotToken,
slackSigningSecret,
slackChannel,
externalEntityLink: 'http://cloudcomponents.org',
additionalInformation:
'Would you like to promote the build to production?',
});
const pipeline = new Pipeline(this, 'MyPipeline', {
pipelineName: 'MyPipeline',
stages: [
{
stageName: 'Source',
actions: [sourceAction],
},
{
stageName: 'Build',
actions: [buildAction],
},
{
stageName: 'Approval',
actions: [approvalAction],
},
],
});
new SlackNotifier(this, 'SlackNotifier', {
pipeline,
slackBotToken,
slackSigningSecret,
slackChannel,
});
}
}
Slack App Settings
Create an app that’s just for your workspace
OAuth & Permissions
Grant the channels::history
-Scope to the Bot in your app and Add the Bot to the configured Slack-Channel
Select Permission Scopes:
Interactive Components
Enter the url of your api from the AWS Api Gateway and append /slack/actions
:
API Reference
See API.md.
Example
See more complete examples.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for cloudcomponents.cdk-codepipeline-slack-1.50.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d4eae5aee7f2ecfcfc845ba23b30b419f2131986d403eeb0f0593e5aa0ea350 |
|
MD5 | e6f8cd78a20b67206de1bd361d1c49fb |
|
BLAKE2b-256 | c4353f69133efb19e8900b104bc75a117b86f6f7453d9c58454abb735865fb70 |
Close
Hashes for cloudcomponents.cdk_codepipeline_slack-1.50.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a677101042f79419ba04bbd6af5f33b970d9ae70ef618056026cde5d22e460c |
|
MD5 | 64b996b4f5c1b8d479b7eb06579887d2 |
|
BLAKE2b-256 | 953c9c2cf65bb321a7f3e75f51ddb7039c5c41a5a54275da5cce810834171c9d |