-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathinteg.cfn-template-from-repo.lit.ts
67 lines (61 loc) · 1.66 KB
/
integ.cfn-template-from-repo.lit.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as codecommit from '../../aws-codecommit';
import * as codepipeline from '../../aws-codepipeline';
import * as cdk from '../../core';
import * as cpactions from '../lib';
const app = new cdk.App({
postCliContext: {
'@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2': false,
},
});
const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-cloudformation');
/// !show
// Source stage: read from repository
const repo = new codecommit.Repository(stack, 'TemplateRepo', {
repositoryName: 'template-repo',
});
const sourceOutput = new codepipeline.Artifact('SourceArtifact');
const source = new cpactions.CodeCommitSourceAction({
actionName: 'Source',
repository: repo,
output: sourceOutput,
trigger: cpactions.CodeCommitTrigger.POLL,
});
const sourceStage = {
stageName: 'Source',
actions: [source],
};
// Deployment stage: create and deploy changeset with manual approval
const stackName = 'OurStack';
const changeSetName = 'StagedChangeSet';
const prodStage = {
stageName: 'Deploy',
actions: [
new cpactions.CloudFormationCreateReplaceChangeSetAction({
actionName: 'PrepareChanges',
stackName,
changeSetName,
adminPermissions: true,
templatePath: sourceOutput.atPath('template.yaml'),
runOrder: 1,
}),
new cpactions.ManualApprovalAction({
actionName: 'ApproveChanges',
runOrder: 2,
}),
new cpactions.CloudFormationExecuteChangeSetAction({
actionName: 'ExecuteChanges',
stackName,
changeSetName,
runOrder: 3,
}),
],
};
new codepipeline.Pipeline(stack, 'Pipeline', {
crossAccountKeys: true,
stages: [
sourceStage,
prodStage,
],
});
/// !hide
app.synth();