Skip to content

Instantly share code, notes, and snippets.

@markilott
Created March 23, 2022 14:23
Show Gist options
  • Save markilott/94a66308b339aa7565d9441ec703a93c to your computer and use it in GitHub Desktop.
Save markilott/94a66308b339aa7565d9441ec703a93c to your computer and use it in GitHub Desktop.
AWS CDK Pipelines GitHub Connections
// Connecting to GitHub as source in a CDK Pipeline
// Method 1 - Personal Access Token and Secret.
// Create a Personal Access Token in GitHub.
// Store the Token in a Secrets Manager Secret, then:
new CodePipeline(this, 'DemoPipeline', {
synth: new ShellStep('Synth', {
input: CodePipelineSource.gitHub('owner/reponame', 'branchname', {
authentication: SecretValue.secretsManager('SecretName', { jsonField: 'TOKEN_FIELD' }),
trigger: GitHubTrigger.WEBHOOK,
}),
commands: [
'npm ci',
'npm run build',
'npx cdk synth',
],
}),
});
// Method 2 - AWS Connector for GitHub (recommended)
// Create a Connector in your Pipeline Account, then:
new CodePipeline(this, 'DemoPipeline', {
synth: new ShellStep('Synth', {
input: CodePipelineSource.connection('owner/reponame', 'branchname', {
connectionArn,
}),
commands: [
'npm ci',
'npm run build',
'npx cdk synth',
],
}),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment