cloudcomponents.cdk-codepipeline-slack


Namecloudcomponents.cdk-codepipeline-slack JSON
Version 2.3.0 PyPI version JSON
download
home_pagehttps://github.com/cloudcomponents/cdk-constructs
SummaryCdk component that provisions a #slack approval workflow and notification messages on codepipeline state changes
upload_time2024-04-17 18:36:22
maintainerNone
docs_urlNone
authorhupe1980
requires_python~=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)

# @cloudcomponents/cdk-codepipeline-slack

[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)
[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)
[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-codepipeline-slack)
[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-codepipeline-slack/)
[![Mentioned in Awesome CDK](https://awesome.re/mentioned-badge.svg)](https://github.com/kolomied/awesome-cdk)

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

![Approval Workflow](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/packages/cdk-codepipeline-slack/assets/approval_workflow.png)

![Review Dialog](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/packages/cdk-codepipeline-slack/assets/review_dialog.png)

## Install

TypeScript/JavaScript:

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

Python:

```bash
pip install cloudcomponents.cdk-codepipeline-slack
```

## How to use

```python
import { SlackApprovalAction, SlackNotifier } from '@cloudcomponents/cdk-codepipeline-slack';
import { Stack, StackProps } from 'aws-cdk-lib';
import { Repository } from 'aws-cdk-lib/aws-codecommit';
import { Pipeline, Artifact } from 'aws-cdk-lib/aws-codepipeline';
import { CodeCommitSourceAction } from 'aws-cdk-lib/aws-codepipeline-actions';
import { Construct } from 'constructs';

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,
    });

    if (typeof process.env.SLACK_BOT_TOKEN === 'undefined') {
      throw new Error('environment variable SLACK_BOT_TOKEN undefined');
    }
    const slackBotToken = process.env.SLACK_BOT_TOKEN;

    if (typeof process.env.SLACK_SIGNING_SECRET === 'undefined') {
      throw new Error('environment variable SLACK_SIGNING_SECRET undefined');
    }
    const slackSigningSecret = process.env.SLACK_SIGNING_SECRET;

    if (typeof process.env.SLACK_CHANNEL_NAME === 'undefined') {
      throw new Error('environment variable SLACK_CHANNEL_NAME undefined');
    }
    const slackChannel = process.env.SLACK_CHANNEL_NAME;

    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: '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:

![OAuth Scopes](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/packages/cdk-codepipeline-slack/assets/oauth_scope.png)

### Interactive Components

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

![Interactive Components](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/packages/cdk-codepipeline-slack/assets/interactive_components.png)

## API Reference

See [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-codepipeline-slack/API.md).

## Example

See more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).

## License

[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-codepipeline-slack/LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cloudcomponents/cdk-constructs",
    "name": "cloudcomponents.cdk-codepipeline-slack",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "hupe1980",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/8c/f8/74dee3961012a18f16c081f947b4b512c07c87b4a886cda38c3d9ff0f61d/cloudcomponents.cdk-codepipeline-slack-2.3.0.tar.gz",
    "platform": null,
    "description": "[![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)\n\n# @cloudcomponents/cdk-codepipeline-slack\n\n[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)\n[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)\n[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-codepipeline-slack)\n[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-codepipeline-slack/)\n[![Mentioned in Awesome CDK](https://awesome.re/mentioned-badge.svg)](https://github.com/kolomied/awesome-cdk)\n\n> Cdk component that provisions a #slack approval workflow and notification messages on codepipeline state changes\n\n![Approval Workflow](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/packages/cdk-codepipeline-slack/assets/approval_workflow.png)\n\n![Review Dialog](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/packages/cdk-codepipeline-slack/assets/review_dialog.png)\n\n## Install\n\nTypeScript/JavaScript:\n\n```bash\nnpm install --save @cloudcomponents/cdk-codepipeline-slack\n```\n\nPython:\n\n```bash\npip install cloudcomponents.cdk-codepipeline-slack\n```\n\n## How to use\n\n```python\nimport { SlackApprovalAction, SlackNotifier } from '@cloudcomponents/cdk-codepipeline-slack';\nimport { Stack, StackProps } from 'aws-cdk-lib';\nimport { Repository } from 'aws-cdk-lib/aws-codecommit';\nimport { Pipeline, Artifact } from 'aws-cdk-lib/aws-codepipeline';\nimport { CodeCommitSourceAction } from 'aws-cdk-lib/aws-codepipeline-actions';\nimport { Construct } from 'constructs';\n\nexport class CodePipelineSlackApprovalStack extends Stack {\n  constructor(scope: Construct, id: string, props?: StackProps) {\n    super(scope, id, props);\n\n    const repository = new Repository(this, 'Repository', {\n      repositoryName: 'MyRepositoryName',\n    });\n\n    const sourceArtifact = new Artifact();\n\n    const sourceAction = new CodeCommitSourceAction({\n      actionName: 'CodeCommit',\n      repository,\n      output: sourceArtifact,\n    });\n\n    if (typeof process.env.SLACK_BOT_TOKEN === 'undefined') {\n      throw new Error('environment variable SLACK_BOT_TOKEN undefined');\n    }\n    const slackBotToken = process.env.SLACK_BOT_TOKEN;\n\n    if (typeof process.env.SLACK_SIGNING_SECRET === 'undefined') {\n      throw new Error('environment variable SLACK_SIGNING_SECRET undefined');\n    }\n    const slackSigningSecret = process.env.SLACK_SIGNING_SECRET;\n\n    if (typeof process.env.SLACK_CHANNEL_NAME === 'undefined') {\n      throw new Error('environment variable SLACK_CHANNEL_NAME undefined');\n    }\n    const slackChannel = process.env.SLACK_CHANNEL_NAME;\n\n    const approvalAction = new SlackApprovalAction({\n      actionName: 'SlackApproval',\n      slackBotToken,\n      slackSigningSecret,\n      slackChannel,\n      externalEntityLink: 'http://cloudcomponents.org',\n      additionalInformation: 'Would you like to promote the build to production?',\n    });\n\n    const pipeline = new Pipeline(this, 'MyPipeline', {\n      pipelineName: 'MyPipeline',\n      stages: [\n        {\n          stageName: 'Source',\n          actions: [sourceAction],\n        },\n        {\n          stageName: 'Approval',\n          actions: [approvalAction],\n        },\n      ],\n    });\n\n    new SlackNotifier(this, 'SlackNotifier', {\n      pipeline,\n      slackBotToken,\n      slackSigningSecret,\n      slackChannel,\n    });\n  }\n}\n```\n\n## Slack App Settings\n\nCreate an app that\u2019s just for your workspace\n\n### OAuth & Permissions\n\nGrant the `channels::history`-Scope to the Bot in your app and Add the Bot to the configured Slack-Channel\n\nSelect Permission Scopes:\n\n![OAuth Scopes](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/packages/cdk-codepipeline-slack/assets/oauth_scope.png)\n\n### Interactive Components\n\nEnter the url of your api from the AWS Api Gateway and append `/slack/actions`:\n\n![Interactive Components](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/packages/cdk-codepipeline-slack/assets/interactive_components.png)\n\n## API Reference\n\nSee [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-codepipeline-slack/API.md).\n\n## Example\n\nSee more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).\n\n## License\n\n[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-codepipeline-slack/LICENSE)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cdk component that provisions a #slack approval workflow and notification messages on codepipeline state changes",
    "version": "2.3.0",
    "project_urls": {
        "Homepage": "https://github.com/cloudcomponents/cdk-constructs",
        "Source": "https://github.com/cloudcomponents/cdk-constructs.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5aa676f31ccb90ddee6179c9285036925f559e76d51ad770c1290db79d75c660",
                "md5": "7bc503842ff809b106fab740716d5bf9",
                "sha256": "df6c39c9acaf0bea14a71d226a623535eb2c34419401121b4e2dfe5422d156ac"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk_codepipeline_slack-2.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7bc503842ff809b106fab740716d5bf9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 4676251,
            "upload_time": "2024-04-17T18:36:04",
            "upload_time_iso_8601": "2024-04-17T18:36:04.906996Z",
            "url": "https://files.pythonhosted.org/packages/5a/a6/76f31ccb90ddee6179c9285036925f559e76d51ad770c1290db79d75c660/cloudcomponents.cdk_codepipeline_slack-2.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8cf874dee3961012a18f16c081f947b4b512c07c87b4a886cda38c3d9ff0f61d",
                "md5": "877fa65a52e618b933f7a4643c0aa08d",
                "sha256": "571bc0e3830d5614b6711e8325bd9d2583230310995a56a157d1c472f8e7e8c9"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk-codepipeline-slack-2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "877fa65a52e618b933f7a4643c0aa08d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 4677706,
            "upload_time": "2024-04-17T18:36:22",
            "upload_time_iso_8601": "2024-04-17T18:36:22.773264Z",
            "url": "https://files.pythonhosted.org/packages/8c/f8/74dee3961012a18f16c081f947b4b512c07c87b4a886cda38c3d9ff0f61d/cloudcomponents.cdk-codepipeline-slack-2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 18:36:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cloudcomponents",
    "github_project": "cdk-constructs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cloudcomponents.cdk-codepipeline-slack"
}
        
Elapsed time: 0.22827s