Skip to main content

AWS CDK Construct Library to interact with GitHub's API.

Project description

npm version PyPI version release cdk-constructs: Experimental

CDK-GitHub

AWS CDK v2 L3 constructs for GitHub.

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 Terraform GitHub Provider.

Internally AWS CloudFormation custom resources will be used to track GitHub resources (such as Secrets).

Installation

JavaScript/TypeScript: npm install cdk-github

Python: pip install cdk-github

Constructs

This library provides the following constructs:

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

ActionSecret

import { ActionSecret } from 'cdk-github';

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

    const sourceSecret = Secret.fromSecretNameV2(this, 'secretToStoreInGitHub', 'testcdkgithub');
    const githubTokenSecret = Secret.fromSecretNameV2(this, 'ghSecret', 'GITHUB_TOKEN');

    new ActionSecret(this, 'GitHubActionSecret', {
      githubTokenSecret,
      repositoryName: 'cdk-github',
      repositoryOwner: 'wtfjoke',
      repositorySecretName: 'aRandomGitHubSecret',
      sourceSecret,
    });
  }
}

See full example in ActionSecretStack

Python

import cdkgithub

class ActionSecretStack(Stack):
    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        source_secret = sm.Secret.from_secret_name_v2(
            self, "secretToStoreInGitHub", "testcdkgithub"
        )
        github_token_secret = sm.Secret.from_secret_name_v2(
            self, "ghSecret", "GITHUB_TOKEN"
        )
        cdkgithub.ActionSecret(
            self,
            "GitHubActionSecret",
            github_token_secret=github_token_secret,
            repository_name="cdk-github",
            repository_owner="wtfjoke",
            repository_secret_name="aRandomPythonGitHubSecret",
            source_secret=source_secret,
        )

Please note: the module name is cdkgithub and not cdk-github.

ActionEnvironmentSecret

import { ActionEnvironmentSecret } from 'cdk-github';

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

    const sourceSecret = Secret.fromSecretNameV2(this, 'secretToStoreInGitHub', 'testcdkgithub');
    const githubTokenSecret = Secret.fromSecretNameV2(this, 'ghSecret', 'GITHUB_TOKEN');

    new ActionEnvironmentSecret(this, 'GitHubActionEnvironmentSecret', {
      githubTokenSecret,
      environment: 'dev',
      repositoryName: 'cdk-github',
      repositoryOwner: 'wtfjoke',
      repositorySecretName: 'aRandomGitHubSecret',
      sourceSecret,
    });
  }
}

See full example in ActionEnvironmentSecretStack

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk-github-0.0.6.tar.gz (2.6 MB view hashes)

Uploaded Source

Built Distribution

cdk_github-0.0.6-py3-none-any.whl (2.6 MB view hashes)

Uploaded Python 3

Supported by

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