in lib/cicd-stack.ts [38:81]
constructor(scope: cdk.Construct, id: string, props: CicdStackProps) {
super(scope, id, props)
// Get S3 Bucket Name
const artifactsBucketName = ssm.StringParameter.fromStringParameterName(this, 'artifactsBucketName',
`${props.ssmRoot}/buckets/cicdArtifactsBucketName`)
const artifactsBucket = Bucket.fromBucketName(this, 'artifactsBucket', artifactsBucketName.stringValue)
// Push assume-cross-account-role.env to S3
let ts = Date.now()
new s3deploy.BucketDeployment(this, 'DeployAssumeRole', {
sources: [s3deploy.Source.asset('./scripts')],
destinationBucket: artifactsBucket,
destinationKeyPrefix: 'admin/cross-account',
metadata: { 'timestamp': ts.toString() }
});
// Get Lambda email handler function
const emailHandlerArn = ssm.StringParameter.fromStringParameterName(this, 'emailHandlerArn',
`${props.ssmRoot}/lambda/cicd-email-handler`)
const emailHandler = lambda.Function.fromFunctionArn(this, 'emailHandler', emailHandlerArn.stringValue)
// Get Lambda semver handler function
const semverHandlerArn = ssm.StringParameter.fromStringParameterName(this, 'semverHandlerArn',
`${props.ssmRoot}/lambda/cicd-semver-handler`)
const semverHandler = lambda.Function.fromFunctionArn(this, 'semverHandler', semverHandlerArn.stringValue)
// Parse config.repos
for (let repo of props.repos){
const pipelineName = `${props.prefix}-${repo.pipelineName}-${repo.branch}`.replace(/\/|_/g, '-')
const modulePipelineRole = new PipelineRole(this, `${pipelineName}PipelineRole`)
new SimpleCicdPipeline(this, `${pipelineName}`, {
artifactsBucket,
prefix: props.prefix,
ssmRoot: props.ssmRoot,
repo: repo,
pipelineName,
modulePipelineRole,
emailHandler,
semverHandler
})
}
}