in cdk-pipeline/lib/cdk-pipeline-stack.ts [35:86]
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const stack = cdk.Stack.of(this);
// Create an empty AWS CodePipeline.
const pipeline = new codepipeline.Pipeline(this, 'EksDeployPipeline', {
pipelineName: this.pipelineName,
restartExecutionOnUpdate: true,
});
// import the existing CodeCommit repo.
const repo = codecommit.Repository.fromRepositoryName(this, 'SourceRepo', this.codecommitRepoName);
const sourceOutput = new codepipeline.Artifact();
const sourceAction = new codepipeline_actions.CodeCommitSourceAction({
actionName: 'CodeCommit',
repository: repo,
branch: 'main',
output: sourceOutput,
});
// Create the CodeBuild step of validating K8S manifest files via conftest
const k8sValidationAction = this.k8sValidationAction(sourceOutput);
// Create a manual approval step
const manualApproval = new codepipeline_actions.ManualApprovalAction({
actionName: 'ApproveDeployment',
runOrder: 1
});
// Create the CodeBuild step to deploy the CDK app via cdk commands
const cdkDeployAction = this.cdkDeployAction(sourceOutput, 2);
// Add S3 source action to the pipline
pipeline.addStage({
stageName: 'Source',
actions: [sourceAction],
});
// Add CodeBuid step of validating K8S manifest files to the pipeline.
pipeline.addStage({
stageName: 'ValidateK8sManifests',
actions: [k8sValidationAction],
})
// Add the EKS workload deployment stage
pipeline.addStage({
stageName: 'DeployEksWordloads',
actions: [manualApproval, cdkDeployAction],
});
}