Package: cdk-github
CDK-GitHubGitHub Constructs for use inAWS 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 officialTerraform GitHub Provider.InternallyAWS CloudFormation custom resourcesandoctokitare used to manage GitHub resources (such as Secrets).🔧 InstallationJavaScript/TypeScript:npm install cdk-githubPython:pip install cdk-githubJavaMaven:<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#
Seehttps://www.nuget.org/packages/CdkGithub📚 ConstructsThis library provides the following constructs:ActionEnvironmentSecret- Creates aGitHub Action environment secretfrom a given AWS Secrets Manager secret.ActionSecret- Creates aGitHub Action (repository) secretfrom 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.🔓 AuthenticationCurrently the constructs only support authentication via aGitHub Personal Access Token. The token needs to be a stored in a AWS SecretsManager Secret and passed to the construct as parameter.👩‍🏫 ExamplesThe API documentation and examples in different languages are available onConstruct Hub.
All (typescript) examples can be found in the folderexamples.ActionSecretimport{Secret}from'aws-cdk-lib/aws-secretsmanager';import{ActionSecret}from'cdk-github';exportclassActionSecretStackextendsStack{constructor(scope:Construct,id:string,props?:StackProps){super(scope,id,props);constgithubTokenSecret=Secret.fromSecretNameV2(this,'ghSecret','GITHUB_TOKEN');constsourceSecret=Secret.fromSecretNameV2(this,'secretToStoreInGitHub','testcdkgithub');newActionSecret(this,'GitHubActionSecret',{githubTokenSecret,repository:{name:'cdk-github',owner:'wtfjoke'},repositorySecretName:'A_RANDOM_GITHUB_SECRET',sourceSecret,});}}ActionEnvironmentSecretimport{Secret}from'aws-cdk-lib/aws-secretsmanager';import{ActionEnvironmentSecret}from'cdk-github';exportclassActionEnvironmentSecretStackextendsStack{constructor(scope:Construct,id:string,props?:StackProps){super(scope,id,props);constgithubTokenSecret=Secret.fromSecretNameV2(this,'ghSecret','GITHUB_TOKEN');constsourceSecret=Secret.fromSecretNameV2(this,'secretToStoreInGitHub','testcdkgithub');newActionEnvironmentSecret(this,'GitHubActionEnvironmentSecret',{githubTokenSecret,environment:'dev',repository:{name:'cdk-github',owner:'wtfjoke'},repositorySecretName:'A_RANDOM_GITHUB_SECRET',sourceSecret,});}}GitHubResourceimport{Secret}from'aws-cdk-lib/aws-secretsmanager';import{StringParameter}from'aws-cdk-lib/aws-ssm';import{GitHubResource}from'cdk-github';exportclassGitHubResourceIssueStackextendsStack{constructor(scope:Construct,id:string,props?:StackProps){super(scope,id,props);constgithubTokenSecret=Secret.fromSecretNameV2(this,'ghSecret','GITHUB_TOKEN');//optionalconstwriteResponseToSSMParameter=StringParameter.fromSecureStringParameterAttributes(this,'responseBody',{parameterName:'/cdk-github/encrypted-response'});newGitHubResource(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,});}}💖 ContributingContributions of all kinds are welcome! Check out ourcontributing guide.