@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:
npm install @github-actions-cdk/aws-cdk
or
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:
// 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 for details on how to get involved.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Metadata
Release files for github-actions-cdk.aws-cdk 0.0.23
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| github_actions_cdk_aws_cdk-0.0.23.tar.gz | 143.5 kB | Without provenance | Details for github_actions_cdk_aws_cdk-0.0.23.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| github_actions_cdk.aws_cdk-0.0.23-py3-none-any.whl | Python 3 | none | any | Details for github_actions_cdk.aws_cdk-0.0.23-py3-none-any.whl |
Total release size: 285.2 kB
Release files / github_actions_cdk_aws_cdk-0.0.23.tar.gz
| Download URL | github_actions_cdk_aws_cdk-0.0.23.tar.gz |
|---|---|
| Size | 143.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eab78a7a734c3b1bf79d9687162cb36ba2acd2ae7e5018b5f1a0588a183a58ed
|
|
BLAKE2b-256 checksum How to use checksums |
b16b6d17d917b5e989d63ee6d4ba6c6b1c8d5a004413bd596c9162a32249ad80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / github_actions_cdk.aws_cdk-0.0.23-py3-none-any.whl
| Download URL | github_actions_cdk.aws_cdk-0.0.23-py3-none-any.whl |
|---|---|
| Size | 141.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7116cb9a39508df38f1d6451150a02660745393fe3588d3b535a204869662783
|
|
BLAKE2b-256 checksum How to use checksums |
77686cbc3c63dc3cef595666c2ed4d5eb4acec9c7cefbca79933fdce3773e012
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for github-actions-cdk.aws-cdk 0.0.23
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.