CDK-GitHub
GitHub Constructs for use in AWS CDK .
This project aims to make GitHub's API accessible through CDK with various helper constructs to create resources in GitHub. The target is to replicate most of the functionality of the official Terraform GitHub Provider.
Internally AWS CloudFormation custom resources and octokit are used to manage GitHub resources (such as Secrets).
🔧 Installation
JavaScript/TypeScript:
npm install cdk-github
Python:
pip install cdk-github
Java
Maven:
<dependency>
<groupId>io.github.wtfjoke</groupId>
<artifactId>cdk-github</artifactId>
<version>VERSION</version>
</dependency>
Gradle:
implementation 'io.github.wtfjoke:cdk-github:VERSION'
Gradle (Kotlin):
implementation("io.github.wtfjoke:cdk-github:VERSION")
C# See https://www.nuget.org/packages/CdkGithub
📚 Constructs
This library provides the following constructs:
- ActionEnvironmentSecret - Creates a GitHub Action environment secret from a given AWS Secrets Manager secret.
- ActionSecret - Creates a GitHub Action (repository) secret from a given AWS Secrets Manager secret.
- GitHubResource - Creates an arbitrary GitHub resource. When no suitable construct fits your needs, this construct can be used to create most GitHub resources. It is an L1 construct.
🔓 Authentication
Currently the constructs only support authentication via a GitHub Personal Access Token. The token needs to be a stored in a AWS SecretsManager Secret and passed to the construct as parameter.
👩🏫 Examples
The API documentation and examples in different languages are available on Construct Hub. All (typescript) examples can be found in the folder examples.
ActionSecret
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { ActionSecret } from 'cdk-github';
export class ActionSecretStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const githubTokenSecret = Secret.fromSecretNameV2(this, 'ghSecret', 'GITHUB_TOKEN');
const sourceSecret = Secret.fromSecretNameV2(this, 'secretToStoreInGitHub', 'testcdkgithub');
new ActionSecret(this, 'GitHubActionSecret', {
githubTokenSecret,
repository: { name: 'cdk-github', owner: 'wtfjoke' },
repositorySecretName: 'A_RANDOM_GITHUB_SECRET',
sourceSecret,
});
}
}
ActionEnvironmentSecret
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { ActionEnvironmentSecret } from 'cdk-github';
export class ActionEnvironmentSecretStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const githubTokenSecret = Secret.fromSecretNameV2(this, 'ghSecret', 'GITHUB_TOKEN');
const sourceSecret = Secret.fromSecretNameV2(this, 'secretToStoreInGitHub', 'testcdkgithub');
new ActionEnvironmentSecret(this, 'GitHubActionEnvironmentSecret', {
githubTokenSecret,
environment: 'dev',
repository: { name: 'cdk-github', owner: 'wtfjoke' },
repositorySecretName: 'A_RANDOM_GITHUB_SECRET',
sourceSecret,
});
}
}
GitHubResource
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { StringParameter } from 'aws-cdk-lib/aws-ssm';
import { GitHubResource } from 'cdk-github';
export class GitHubResourceIssueStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const githubTokenSecret = Secret.fromSecretNameV2(this, 'ghSecret', 'GITHUB_TOKEN');
// optional
const writeResponseToSSMParameter = StringParameter.fromSecureStringParameterAttributes(this, 'responseBody', { parameterName: '/cdk-github/encrypted-response' });
new GitHubResource(this, 'GitHubIssue', {
githubTokenSecret,
createRequestEndpoint: 'POST /repos/WtfJoke/dummytest/issues',
createRequestPayload: JSON.stringify({ title: 'Testing cdk-github', body: "I'm opening an issue by using aws cdk 🎉", labels: ['bug'] }),
createRequestResultParameter: 'number',
deleteRequestEndpoint: 'PATCH /repos/WtfJoke/dummytest/issues/:number',
deleteRequestPayload: JSON.stringify({ state: 'closed' }),
writeResponseToSSMParameter,
});
}
}
💖 Contributing
Contributions of all kinds are welcome! Check out our contributing guide.
Metadata
Release files for cdk-github 0.0.57
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 |
|---|---|---|---|---|
| cdk-github-0.0.57.tar.gz | 3.1 MB | Without provenance | Details for cdk-github-0.0.57.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cdk_github-0.0.57-py3-none-any.whl | Python 3 | none | any | Details for cdk_github-0.0.57-py3-none-any.whl |
Total release size: 6.2 MB
Release files / cdk-github-0.0.57.tar.gz
| Download URL | cdk-github-0.0.57.tar.gz |
|---|---|
| Size | 3.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7f3461d1380a7fb64cd0ffb6ff4a323979520f7d5107b61c9e649f5fcc26cdc
|
|
BLAKE2b-256 checksum How to use checksums |
a9dd383ab4ae2aaa57875d840fc9e16575a213cb5e0360da7719a6d3af26c16e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / cdk_github-0.0.57-py3-none-any.whl
| Download URL | cdk_github-0.0.57-py3-none-any.whl |
|---|---|
| Size | 3.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28e6bb4d29c867f2aef0451520dcb45362b32e49cb3b0ad7a4f9ea48764b001f
|
|
BLAKE2b-256 checksum How to use checksums |
62f00d297379d61a75cec425d6cef5db10ff1315a0fa6959cf036e3c99f16df6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for cdk-github 0.0.57
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.