Skip to main content

Cdk component that provisions a #slack approval workflow and notification messages on codepipeline state changes

Project description

cloudcomponents Logo

@cloudcomponents/cdk-codepipeline-slack

Build Status cdkdx typescript python Mentioned in Awesome CDK

Cdk component that provisions a #slack approval workflow and notification messages on codepipeline state changes

Approval Workflow

Review Dialog

Install

TypeScript/JavaScript:

npm install --save @cloudcomponents/cdk-codepipeline-slack

Python:

pip install cloudcomponents.cdk-codepipeline-slack

How to use

# Example automatically generated from non-compiling source. May contain errors.
from aws_cdk.aws_codepipeline import StageProps, StageProps, StageProps
from aws_cdk.core import Construct, Stack, StackProps
from aws_cdk.aws_codecommit import Repository
from aws_cdk.aws_codepipeline import Pipeline, Artifact
from aws_cdk.aws_codepipeline_actions import CodeCommitSourceAction, CodeBuildAction
from aws_cdk.aws_codebuild import PipelineProject

from cloudcomponents.cdk_codepipeline_slack import SlackApprovalAction, SlackNotifier

class CodePipelineSlackApprovalStack(Stack):
    def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, synthesizer=None, terminationProtection=None, analyticsReporting=None):
        super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting)

        repository = Repository(self, "Repository",
            repository_name="MyRepositoryName"
        )

        source_artifact = Artifact()

        source_action = CodeCommitSourceAction(
            action_name="CodeCommit",
            repository=repository,
            output=source_artifact
        )

        project = PipelineProject(self, "MyProject")

        build_action = CodeBuildAction(
            action_name="CodeBuild",
            project=project,
            input=source_artifact
        )

        slack_bot_token = process.env.SLACK_BOT_TOKEN
        slack_signing_secret = process.env.SLACK_SIGNING_SECRET
        slack_channel = process.env.SLACK_CHANNEL_NAME

        approval_action = SlackApprovalAction(
            action_name="SlackApproval",
            slack_bot_token=slack_bot_token,
            slack_signing_secret=slack_signing_secret,
            slack_channel=slack_channel,
            external_entity_link="http://cloudcomponents.org",
            additional_information="Would you like to promote the build to production?"
        )

        pipeline = Pipeline(self, "MyPipeline",
            pipeline_name="MyPipeline",
            stages=[StageProps(
                stage_name="Source",
                actions=[source_action]
            ), StageProps(
                stage_name="Build",
                actions=[build_action]
            ), StageProps(
                stage_name="Approval",
                actions=[approval_action]
            )
            ]
        )

        SlackNotifier(self, "SlackNotifier",
            pipeline=pipeline,
            slack_bot_token=slack_bot_token,
            slack_signing_secret=slack_signing_secret,
            slack_channel=slack_channel
        )

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:

OAuth Scopes

Interactive Components

Enter the url of your api from the AWS Api Gateway and append /slack/actions:

Interactive Components

API Reference

See API.md.

Example

See more complete examples.

License

MIT

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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file cloudcomponents.cdk-codepipeline-slack-1.47.0.tar.gz.

File metadata

  • Download URL: cloudcomponents.cdk-codepipeline-slack-1.47.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for cloudcomponents.cdk-codepipeline-slack-1.47.0.tar.gz
Algorithm Hash digest
SHA256 137accf1981b80257602a70a8f3b69502150967ecec43d5c55cc71ffdcf52580
MD5 9b3fd740da9b48a3a7db85116307a946
BLAKE2b-256 21fd5da23e0334bc2ada95a5c2978cb96868c65ee838552b74aecf5c4a8b01a2

See more details on using hashes here.

File details

Details for the file cloudcomponents.cdk_codepipeline_slack-1.47.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudcomponents.cdk_codepipeline_slack-1.47.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b7d4de5ef0f2fc4bb9ba901ec1a5af7dd3c728895dbb2f1b18cc749ad4f7de5
MD5 073d02a376d336aaa20ebf55a7d5ea95
BLAKE2b-256 f6cb934f486e178aaa4aa2d4b2825ba029c0e64bb1465a3915c855280680f0e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page