export class PipeLineStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const repo = Repository.fromRepositoryName(this, 'XXX', "repo_specification")
const pipeline = new CodePipeline(this, 'DeployPipeline', {
pipelineName: 'DeployPipeline',
selfMutation: false,
synth: new ShellStep('Synth', {
input: CodePipelineSource.codeCommit(repo, 'main'),
commands: ['cd cdk', 'npm ci', 'npm run build', 'npx cdk synth'],
primaryOutputDirectory: 'cdk/cdk.out'
}),
codeBuildDefaults: {
rolePolicy: [
new PolicyStatement({
actions: [
"S3:PutObject"
],
resources: ['*'],
}),
],
},
});
pipeline.addStage(new S3HostingStage(this, "S3HostingStage", WebsiteDomainName), {
post: [
new cdk.pipelines.ShellStep('CreateHtmlUpToS3', {
commands: ['chmod +x build.sh', `./build.sh ${WebsiteDomainName}`]
})
]
});
}
}