github-actions-cdk.aws-cdk


Namegithub-actions-cdk.aws-cdk JSON
Version 0.0.23 PyPI version JSON
download
home_pagehttps://github.com/hupe1980/github-actions-cdk.git
SummaryA TypeScript library for building GitHub Actions pipelines specifically for AWS CDK applications. This library allows developers to define, structure, and automate CI/CD workflows tailored to CDK projects, making it easy to deploy infrastructure through GitHub Actions in a type-safe and modular way.
upload_time2024-11-05 21:01:35
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.
            [![View on Construct Hub](https://constructs.dev/badge?package=%40github-actions-cdk%2Faws-cdk)](https://constructs.dev/packages/@github-actions-cdk/aws-cdk)

# @github-actions-cdk/aws-cdk

**@github-actions-cdk/aws-cdk** is a TypeScript library for building GitHub Actions pipelines specifically for AWS CDK applications. This library allows developers to define, structure, and automate CI/CD workflows tailored to CDK projects, making it easy to deploy infrastructure through GitHub Actions in a type-safe and modular way.

## Key Features

* **Type-Safe Workflow Definition**: Use TypeScript to define GitHub Actions workflows with strict typing, ensuring correctness and reducing errors.
* **Purpose-Built for AWS CDK**: Integrates directly with AWS CDK, making it simple to add deployment stages, manage dependencies, and automate CDK operations.
* **Modular Components**: Quickly set up workflows by creating reusable jobs, triggers, and custom deployment stages.

## Installation

To get started with `@github-actions-cdk/aws-cdk`, install the package using npm or yarn:

```bash
npm install @github-actions-cdk/aws-cdk
```

or

```bash
yarn add @github-actions-cdk/aws-cdk
```

## Getting Started

### Basic Usage

Here’s an example of how to create a GitHub Actions workflow for an AWS CDK app using @github-actions-cdk/aws-cdk in TypeScript:

```python
// main.ts
import { AwsCredentials, GitHubActionsOpenIdConnectProvider, GitHubActionsPipeline, GitHubActionsRole, StageJob, Synth } from '@github-actions-cdk/aws-cdk';
import { RunStep } from 'github-actions-cdk';
import { App, Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';

import { MyStage } from './my-stage';

class GithubActionsStack extends Stack {
    constructor(scope: Construct, id: string, props?: StackProps) {
        super(scope, id, props);

        const provider = GitHubActionsOpenIdConnectProvider.fromGitHubActionsOpenIdConnectProvider(this);

        new GitHubActionsRole(this, 'GitHubActionsRole', {
            provider,
        });

        const pipeline = new GitHubActionsPipeline(this, 'Pipeline', {
            workflowOutdir: `${__dirname}/.github/workflows`,
            preBuild: { steps: (job) => {
                new RunStep(job, 'pre', {
                    run: 'echo "Hello, world!"',
                });
            }},
            synth: new Synth({
                commands: ["npm install", "npm run build"],
            }),
            awsCredentials: AwsCredentials.fromOpenIdConnect({
                gitHubActionsRoleArn: "arn:aws:iam::<account-id>:role/GitHubActionsRole",
            }),
        });

        // a wave deploys all stages concurrently
        const prod = pipeline.addWave('Prod');

        const ACCOUNT = '123456789012';
        prod.addStage(new MyStage(app, 'US', { env: { account: ACCOUNT, region: 'us-east-1' } }), {
            preJobs: [new StageJob("hello-world", {
                name: 'Hello World',
                steps: (job) => {
                    new RunStep(job, 'echo', {
                        run: 'echo "Hello world!"',
                    });
                }
            })],
        });
        prod.addStage(new MyStage(app, 'EU', { env: { account: ACCOUNT, region: 'eu-west-2' } }));
    }
}

const app = new App();
new GithubActionsStack(app, 'GithubActionsStack');

// my-stage.ts
import * as path from 'path';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { App, RemovalPolicy, Stack, Stage, StageProps } from 'aws-cdk-lib';

const assets = path.join(__dirname, 'assets');

export class MyStage extends Stage {
  constructor(scope: App, id: string, props: StageProps = {}) {
    super(scope, id, props);

    const fnStack = new Stack(this, 'FunctionStack');
    const bucketStack = new Stack(this, 'BucketStack');

    const bucket = new s3.Bucket(bucketStack, 'Bucket', {
      autoDeleteObjects: true,
      removalPolicy: RemovalPolicy.DESTROY,
    });

    const fn = new lambda.Function(fnStack, 'Function', {
      code: lambda.Code.fromAsset(path.join(__dirname, 'assets', 'files')),
      handler: 'lambda.handler',
      runtime: lambda.Runtime.PYTHON_3_12,
      environment: {
        BUCKET_NAME: bucket.bucketName, // <-- cross stack reference
      },
    });

    bucket.grantRead(fn);
  }
}
```

## Contributing

Contributions are welcome! Please read the [CONTRIBUTING.md](../../CONTRIBUTING.md) for details on how to get involved.

## License

This project is licensed under the MIT License. See the [LICENSE](../../LICENCE) file for more information.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hupe1980/github-actions-cdk.git",
    "name": "github-actions-cdk.aws-cdk",
    "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/b1/6b/6d17d917b5e989d63ee6d4ba6c6b1c8d5a004413bd596c9162a32249ad80/github_actions_cdk_aws_cdk-0.0.23.tar.gz",
    "platform": null,
    "description": "[![View on Construct Hub](https://constructs.dev/badge?package=%40github-actions-cdk%2Faws-cdk)](https://constructs.dev/packages/@github-actions-cdk/aws-cdk)\n\n# @github-actions-cdk/aws-cdk\n\n**@github-actions-cdk/aws-cdk** is a TypeScript library for building GitHub Actions pipelines specifically for AWS CDK applications. This library allows developers to define, structure, and automate CI/CD workflows tailored to CDK projects, making it easy to deploy infrastructure through GitHub Actions in a type-safe and modular way.\n\n## Key Features\n\n* **Type-Safe Workflow Definition**: Use TypeScript to define GitHub Actions workflows with strict typing, ensuring correctness and reducing errors.\n* **Purpose-Built for AWS CDK**: Integrates directly with AWS CDK, making it simple to add deployment stages, manage dependencies, and automate CDK operations.\n* **Modular Components**: Quickly set up workflows by creating reusable jobs, triggers, and custom deployment stages.\n\n## Installation\n\nTo get started with `@github-actions-cdk/aws-cdk`, install the package using npm or yarn:\n\n```bash\nnpm install @github-actions-cdk/aws-cdk\n```\n\nor\n\n```bash\nyarn add @github-actions-cdk/aws-cdk\n```\n\n## Getting Started\n\n### Basic Usage\n\nHere\u2019s an example of how to create a GitHub Actions workflow for an AWS CDK app using @github-actions-cdk/aws-cdk in TypeScript:\n\n```python\n// main.ts\nimport { AwsCredentials, GitHubActionsOpenIdConnectProvider, GitHubActionsPipeline, GitHubActionsRole, StageJob, Synth } from '@github-actions-cdk/aws-cdk';\nimport { RunStep } from 'github-actions-cdk';\nimport { App, Stack, StackProps } from 'aws-cdk-lib';\nimport { Construct } from 'constructs';\n\nimport { MyStage } from './my-stage';\n\nclass GithubActionsStack extends Stack {\n    constructor(scope: Construct, id: string, props?: StackProps) {\n        super(scope, id, props);\n\n        const provider = GitHubActionsOpenIdConnectProvider.fromGitHubActionsOpenIdConnectProvider(this);\n\n        new GitHubActionsRole(this, 'GitHubActionsRole', {\n            provider,\n        });\n\n        const pipeline = new GitHubActionsPipeline(this, 'Pipeline', {\n            workflowOutdir: `${__dirname}/.github/workflows`,\n            preBuild: { steps: (job) => {\n                new RunStep(job, 'pre', {\n                    run: 'echo \"Hello, world!\"',\n                });\n            }},\n            synth: new Synth({\n                commands: [\"npm install\", \"npm run build\"],\n            }),\n            awsCredentials: AwsCredentials.fromOpenIdConnect({\n                gitHubActionsRoleArn: \"arn:aws:iam::<account-id>:role/GitHubActionsRole\",\n            }),\n        });\n\n        // a wave deploys all stages concurrently\n        const prod = pipeline.addWave('Prod');\n\n        const ACCOUNT = '123456789012';\n        prod.addStage(new MyStage(app, 'US', { env: { account: ACCOUNT, region: 'us-east-1' } }), {\n            preJobs: [new StageJob(\"hello-world\", {\n                name: 'Hello World',\n                steps: (job) => {\n                    new RunStep(job, 'echo', {\n                        run: 'echo \"Hello world!\"',\n                    });\n                }\n            })],\n        });\n        prod.addStage(new MyStage(app, 'EU', { env: { account: ACCOUNT, region: 'eu-west-2' } }));\n    }\n}\n\nconst app = new App();\nnew GithubActionsStack(app, 'GithubActionsStack');\n\n// my-stage.ts\nimport * as path from 'path';\nimport * as lambda from 'aws-cdk-lib/aws-lambda';\nimport * as s3 from 'aws-cdk-lib/aws-s3';\nimport { App, RemovalPolicy, Stack, Stage, StageProps } from 'aws-cdk-lib';\n\nconst assets = path.join(__dirname, 'assets');\n\nexport class MyStage extends Stage {\n  constructor(scope: App, id: string, props: StageProps = {}) {\n    super(scope, id, props);\n\n    const fnStack = new Stack(this, 'FunctionStack');\n    const bucketStack = new Stack(this, 'BucketStack');\n\n    const bucket = new s3.Bucket(bucketStack, 'Bucket', {\n      autoDeleteObjects: true,\n      removalPolicy: RemovalPolicy.DESTROY,\n    });\n\n    const fn = new lambda.Function(fnStack, 'Function', {\n      code: lambda.Code.fromAsset(path.join(__dirname, 'assets', 'files')),\n      handler: 'lambda.handler',\n      runtime: lambda.Runtime.PYTHON_3_12,\n      environment: {\n        BUCKET_NAME: bucket.bucketName, // <-- cross stack reference\n      },\n    });\n\n    bucket.grantRead(fn);\n  }\n}\n```\n\n## Contributing\n\nContributions are welcome! Please read the [CONTRIBUTING.md](../../CONTRIBUTING.md) for details on how to get involved.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](../../LICENCE) file for more information.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A TypeScript library for building GitHub Actions pipelines specifically for AWS CDK applications. This library allows developers to define, structure, and automate CI/CD workflows tailored to CDK projects, making it easy to deploy infrastructure through GitHub Actions in a type-safe and modular way.",
    "version": "0.0.23",
    "project_urls": {
        "Homepage": "https://github.com/hupe1980/github-actions-cdk.git",
        "Source": "https://github.com/hupe1980/github-actions-cdk.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "77686cbc3c63dc3cef595666c2ed4d5eb4acec9c7cefbca79933fdce3773e012",
                "md5": "d59474f74f63509345c4a0f493b07ecb",
                "sha256": "7116cb9a39508df38f1d6451150a02660745393fe3588d3b535a204869662783"
            },
            "downloads": -1,
            "filename": "github_actions_cdk.aws_cdk-0.0.23-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d59474f74f63509345c4a0f493b07ecb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 141616,
            "upload_time": "2024-11-05T21:01:27",
            "upload_time_iso_8601": "2024-11-05T21:01:27.955868Z",
            "url": "https://files.pythonhosted.org/packages/77/68/6cbc3c63dc3cef595666c2ed4d5eb4acec9c7cefbca79933fdce3773e012/github_actions_cdk.aws_cdk-0.0.23-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b16b6d17d917b5e989d63ee6d4ba6c6b1c8d5a004413bd596c9162a32249ad80",
                "md5": "4a1cb81e07957edddee9309b1fe81599",
                "sha256": "eab78a7a734c3b1bf79d9687162cb36ba2acd2ae7e5018b5f1a0588a183a58ed"
            },
            "downloads": -1,
            "filename": "github_actions_cdk_aws_cdk-0.0.23.tar.gz",
            "has_sig": false,
            "md5_digest": "4a1cb81e07957edddee9309b1fe81599",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 143547,
            "upload_time": "2024-11-05T21:01:35",
            "upload_time_iso_8601": "2024-11-05T21:01:35.590103Z",
            "url": "https://files.pythonhosted.org/packages/b1/6b/6d17d917b5e989d63ee6d4ba6c6b1c8d5a004413bd596c9162a32249ad80/github_actions_cdk_aws_cdk-0.0.23.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 21:01:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hupe1980",
    "github_project": "github-actions-cdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "github-actions-cdk.aws-cdk"
}
        
Elapsed time: 0.93875s