Skip to content

Instantly share code, notes, and snippets.

@markilott
Created March 23, 2022 14:39
Show Gist options
  • Save markilott/0e7dc52a21d32d9ec5469307d7ed0465 to your computer and use it in GitHub Desktop.
Save markilott/0e7dc52a21d32d9ec5469307d7ed0465 to your computer and use it in GitHub Desktop.
AWS CDK Pipeline GitHub Source
export class PipelineStack extends Stack {
/**
* Creates a deployment Pipeline.
* Can be run for each environment to create separate
* pipelines for each.
*
* @param {Construct} scope
* @param {string} id
* @param {StackProps=} props
*/
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
// Pipeline using CDK Pipelines
const pipeline = new CodePipeline(this, 'DemoPipeline', {
pipelineName: 'DemoPipeline',
crossAccountKeys: true, // Required if deploying cross-account
synth: new ShellStep('Synth', {
input: CodePipelineSource.connection('owner/reponame', 'branchname', {
// AWS Connector for GitHub Arn
connectionArn: `arn:aws:codestar-connections:${this.region}:${this.account}:connection/96f901dd-d2c2-4f73-a198-xxxxxxxxxxxx`,
}),
commands: [
'npm ci',
'npm run build',
'npx cdk synth',
],
}),
});
// Connect your Application Stage (which contains the Stacks)
const applicationStage = new ApplicationStage(this, 'DeployStage', {
env: {
account: 'Target Account Number',
region: 'Target region',
},
version: '',
});
pipeline.addStage(applicationStage);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment