@flit/cdk-pipeline 1.0.25 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +597 -158
- package/LICENSE.txt +202 -0
- package/README.md +340 -2
- package/dist/artifact.js +1 -1
- package/dist/code-commit-source-segment.js +2 -2
- package/dist/code-star-source-segment.js +2 -2
- package/dist/git-hub-source-segment.js +2 -2
- package/dist/pipeline-segment.d.ts +24 -2
- package/dist/pipeline-segment.js +76 -6
- package/dist/pipeline.js +3 -2
- package/dist/publish-assets-action.js +3 -6
- package/dist/s3-source-segment.js +2 -2
- package/dist/segment.js +2 -2
- package/dist/source-segment.js +1 -1
- package/dist/stack-segment.d.ts +3 -3
- package/dist/stack-segment.js +46 -49
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -21
- package/src/pipeline-segment.ts +112 -4
- package/src/pipeline.ts +6 -1
- package/src/publish-assets-action.ts +1 -4
- package/src/stack-segment.ts +51 -51
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flit/cdk-pipeline",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A highly customizable and extensible CI/CD pipeline intended as alternative to CDK's native CodePipeline",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aws",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"codepipeline",
|
|
12
12
|
"cicd"
|
|
13
13
|
],
|
|
14
|
-
"homepage": "https://
|
|
15
|
-
"bugs": "https://github.com/
|
|
14
|
+
"homepage": "https://github.com/jumper-de/cdk-pipeline",
|
|
15
|
+
"bugs": "https://github.com/jumper-de/cdk-pipeline/issues",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/
|
|
18
|
+
"url": "https://github.com/jumper-de/cdk-pipeline.git"
|
|
19
19
|
},
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"author": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"./dist",
|
|
30
30
|
"./src",
|
|
31
31
|
"./.jsii",
|
|
32
|
+
"./LICENSE.txt",
|
|
32
33
|
"./README.md"
|
|
33
34
|
],
|
|
34
35
|
"scripts": {
|
|
@@ -36,20 +37,16 @@
|
|
|
36
37
|
"prepack": "jsii"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^
|
|
40
|
-
"aws-cdk-lib": "
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"jsii-pacmak": "^1.94.0",
|
|
46
|
-
"ts-jest": "^29.1.2",
|
|
47
|
-
"ts-node": "^10.9.2",
|
|
48
|
-
"typescript": "^5.3.3"
|
|
40
|
+
"@types/node": "^22.7.8",
|
|
41
|
+
"aws-cdk-lib": "2.163.0",
|
|
42
|
+
"constructs": "10.4.2",
|
|
43
|
+
"jsii": "^5.5.4",
|
|
44
|
+
"jsii-pacmak": "^1.104.0",
|
|
45
|
+
"typescript": "^5.6.3"
|
|
49
46
|
},
|
|
50
47
|
"peerDependencies": {
|
|
51
|
-
"aws-cdk-lib": "
|
|
52
|
-
"constructs": "
|
|
48
|
+
"aws-cdk-lib": "2.163.0",
|
|
49
|
+
"constructs": "10.4.2"
|
|
53
50
|
},
|
|
54
51
|
"publishConfig": {
|
|
55
52
|
"access": "public"
|
|
@@ -82,9 +79,5 @@
|
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
81
|
},
|
|
85
|
-
"stability": "stable"
|
|
86
|
-
"typedocOptions": {
|
|
87
|
-
"entryPoints": "./src/index.ts",
|
|
88
|
-
"readme": "./TYPEDOC.md"
|
|
89
|
-
}
|
|
82
|
+
"stability": "stable"
|
|
90
83
|
}
|
package/src/pipeline-segment.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BuildEnvironmentVariable,
|
|
3
|
+
BuildSpec,
|
|
4
|
+
mergeBuildSpecs,
|
|
5
|
+
Project,
|
|
6
|
+
ProjectProps,
|
|
7
|
+
} from "aws-cdk-lib/aws-codebuild";
|
|
8
|
+
import { Stack } from "aws-cdk-lib";
|
|
9
|
+
import { IAction } from "aws-cdk-lib/aws-codepipeline";
|
|
10
|
+
import {
|
|
11
|
+
CloudFormationCreateReplaceChangeSetAction,
|
|
12
|
+
CloudFormationExecuteChangeSetAction,
|
|
13
|
+
CodeBuildAction,
|
|
14
|
+
ManualApprovalAction,
|
|
15
|
+
} from "aws-cdk-lib/aws-codepipeline-actions";
|
|
16
|
+
import * as path from "path";
|
|
2
17
|
|
|
3
18
|
import { Artifact } from "./artifact";
|
|
4
19
|
import { Segment, SegmentConstructed } from "./segment";
|
|
5
|
-
import { StackSegmentConstructed } from "./stack-segment";
|
|
6
20
|
import { Pipeline } from "./pipeline";
|
|
21
|
+
import { PublishAssetsAction } from "./publish-assets-action";
|
|
7
22
|
|
|
8
23
|
export interface PipelineSegmentProps {
|
|
9
24
|
/**
|
|
@@ -14,7 +29,7 @@ export interface PipelineSegmentProps {
|
|
|
14
29
|
* The command(s) to build the stack.
|
|
15
30
|
* @example "cdk synth StackName --strict --exclusively"
|
|
16
31
|
*/
|
|
17
|
-
readonly
|
|
32
|
+
readonly project: ProjectProps;
|
|
18
33
|
/**
|
|
19
34
|
* The environmental variables for the build stage.
|
|
20
35
|
*/
|
|
@@ -62,7 +77,7 @@ export class PipelineSegment extends Segment {
|
|
|
62
77
|
}
|
|
63
78
|
|
|
64
79
|
construct(scope: Pipeline): SegmentConstructed {
|
|
65
|
-
return new
|
|
80
|
+
return new PipelineSegmentConstructed(scope, `Deploy${scope.stackName}`, {
|
|
66
81
|
...this.props,
|
|
67
82
|
stack: scope,
|
|
68
83
|
input: this.inputs[0],
|
|
@@ -70,3 +85,96 @@ export class PipelineSegment extends Segment {
|
|
|
70
85
|
});
|
|
71
86
|
}
|
|
72
87
|
}
|
|
88
|
+
|
|
89
|
+
export interface PipelineSegmentConstructedProps {
|
|
90
|
+
readonly stack: Stack;
|
|
91
|
+
readonly project: ProjectProps;
|
|
92
|
+
readonly environmentVariables?: { [key: string]: BuildEnvironmentVariable };
|
|
93
|
+
readonly stackName?: string;
|
|
94
|
+
readonly account?: string;
|
|
95
|
+
readonly region?: string;
|
|
96
|
+
readonly input: Artifact;
|
|
97
|
+
readonly extraInputs?: Artifact[];
|
|
98
|
+
readonly output?: Artifact;
|
|
99
|
+
readonly outputFileName?: string;
|
|
100
|
+
readonly manualApproval?: Boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class PipelineSegmentConstructed extends SegmentConstructed {
|
|
104
|
+
readonly name: string;
|
|
105
|
+
readonly actions: IAction[];
|
|
106
|
+
|
|
107
|
+
constructor(
|
|
108
|
+
scope: Pipeline,
|
|
109
|
+
id: string,
|
|
110
|
+
props: PipelineSegmentConstructedProps,
|
|
111
|
+
) {
|
|
112
|
+
super(scope, id);
|
|
113
|
+
|
|
114
|
+
this.name = props.stack.stackName;
|
|
115
|
+
|
|
116
|
+
const buildArtifact = props.output || new Artifact();
|
|
117
|
+
|
|
118
|
+
this.actions = [
|
|
119
|
+
new CodeBuildAction({
|
|
120
|
+
actionName: "Build",
|
|
121
|
+
runOrder: 1,
|
|
122
|
+
input: props.input,
|
|
123
|
+
extraInputs: props.extraInputs,
|
|
124
|
+
outputs: [buildArtifact],
|
|
125
|
+
environmentVariables: props.environmentVariables,
|
|
126
|
+
project: new Project(this, "UpdateCodeBuild", {
|
|
127
|
+
...props.project,
|
|
128
|
+
buildSpec: props.project.buildSpec
|
|
129
|
+
? mergeBuildSpecs(
|
|
130
|
+
props.project.buildSpec,
|
|
131
|
+
BuildSpec.fromObject({
|
|
132
|
+
artifacts: {
|
|
133
|
+
files: [path.join(scope.buildDir, "**/*")],
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
)
|
|
137
|
+
: BuildSpec.fromObject({
|
|
138
|
+
artifacts: {
|
|
139
|
+
files: [path.join(scope.buildDir, "**/*")],
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
}),
|
|
143
|
+
}),
|
|
144
|
+
new PublishAssetsAction(this, "PublishAssets", {
|
|
145
|
+
actionName: "PublishAssets",
|
|
146
|
+
runOrder: 2,
|
|
147
|
+
input: buildArtifact,
|
|
148
|
+
manifestPath: scope.buildDir,
|
|
149
|
+
}),
|
|
150
|
+
new CloudFormationCreateReplaceChangeSetAction({
|
|
151
|
+
actionName: "PrepareChanges",
|
|
152
|
+
runOrder: 3,
|
|
153
|
+
stackName: props.stackName ? props.stackName : props.stack.stackName,
|
|
154
|
+
account: props.account,
|
|
155
|
+
region: props.region,
|
|
156
|
+
changeSetName: `${props.stack.stackName}Changes`,
|
|
157
|
+
adminPermissions: true,
|
|
158
|
+
templatePath: buildArtifact.atPath(
|
|
159
|
+
path.join(scope.buildDir, props.stack.templateFile),
|
|
160
|
+
),
|
|
161
|
+
}),
|
|
162
|
+
...(props.manualApproval
|
|
163
|
+
? [
|
|
164
|
+
new ManualApprovalAction({
|
|
165
|
+
actionName: "ApproveChanges",
|
|
166
|
+
runOrder: 4,
|
|
167
|
+
}),
|
|
168
|
+
]
|
|
169
|
+
: []),
|
|
170
|
+
new CloudFormationExecuteChangeSetAction({
|
|
171
|
+
actionName: "ExecuteChanges",
|
|
172
|
+
runOrder: props.manualApproval ? 5 : 4,
|
|
173
|
+
stackName: props.stackName ? props.stackName : props.stack.stackName,
|
|
174
|
+
account: props.account,
|
|
175
|
+
region: props.region,
|
|
176
|
+
changeSetName: `${props.stack.stackName}Changes`,
|
|
177
|
+
}),
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
}
|
package/src/pipeline.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { App, Stack, StackProps } from "aws-cdk-lib";
|
|
2
2
|
import { Construct } from "constructs";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Pipeline as AwsPipeline,
|
|
5
|
+
IAction,
|
|
6
|
+
PipelineType,
|
|
7
|
+
} from "aws-cdk-lib/aws-codepipeline";
|
|
4
8
|
import * as path from "path";
|
|
5
9
|
|
|
6
10
|
import { Artifact } from "./artifact";
|
|
@@ -68,6 +72,7 @@ export class Pipeline extends Stack {
|
|
|
68
72
|
new AwsPipeline(this, "Pipeline", {
|
|
69
73
|
pipelineName: props.pipelineName,
|
|
70
74
|
restartExecutionOnUpdate: true,
|
|
75
|
+
pipelineType: PipelineType.V2,
|
|
71
76
|
stages: [
|
|
72
77
|
{
|
|
73
78
|
stageName: "Source",
|
|
@@ -96,10 +96,7 @@ export class PublishAssetsAction extends Construct implements IAction {
|
|
|
96
96
|
"runtime-versions": {
|
|
97
97
|
nodejs: "latest",
|
|
98
98
|
},
|
|
99
|
-
commands: [
|
|
100
|
-
"n lts",
|
|
101
|
-
"npm i -g npm@latest @flit/publish-cdk-assets@latest",
|
|
102
|
-
],
|
|
99
|
+
commands: ["npm i -g npm@latest @flit/publish-cdk-assets@latest"],
|
|
103
100
|
},
|
|
104
101
|
build: {
|
|
105
102
|
commands: `pca ${
|
package/src/stack-segment.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { Stack } from "aws-cdk-lib";
|
|
|
2
2
|
import {
|
|
3
3
|
BuildEnvironmentVariable,
|
|
4
4
|
BuildSpec,
|
|
5
|
-
|
|
6
|
-
LinuxBuildImage,
|
|
5
|
+
mergeBuildSpecs,
|
|
7
6
|
Project,
|
|
7
|
+
ProjectProps,
|
|
8
8
|
} from "aws-cdk-lib/aws-codebuild";
|
|
9
9
|
import { IAction } from "aws-cdk-lib/aws-codepipeline";
|
|
10
10
|
import {
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
import { IRole } from "aws-cdk-lib/aws-iam";
|
|
17
17
|
import * as path from "path";
|
|
18
18
|
|
|
19
|
-
import { PublishAssetsAction } from "./publish-assets-action";
|
|
20
19
|
import { Artifact } from "./artifact";
|
|
21
20
|
import { Segment, SegmentConstructed } from "./segment";
|
|
22
21
|
import { Pipeline } from "./pipeline";
|
|
22
|
+
import { PublishAssetsAction } from "./publish-assets-action";
|
|
23
23
|
|
|
24
24
|
export interface StackSegmentProps {
|
|
25
25
|
/**
|
|
@@ -34,7 +34,7 @@ export interface StackSegmentProps {
|
|
|
34
34
|
* The command(s) to build the stack.
|
|
35
35
|
* @example "cdk synth StackName --strict --exclusively"
|
|
36
36
|
*/
|
|
37
|
-
readonly
|
|
37
|
+
readonly project?: ProjectProps;
|
|
38
38
|
/**
|
|
39
39
|
* The role for the build stage.
|
|
40
40
|
*/
|
|
@@ -99,7 +99,7 @@ export class StackSegment extends Segment {
|
|
|
99
99
|
|
|
100
100
|
export interface StackSegmentConstructedProps {
|
|
101
101
|
readonly stack: Stack;
|
|
102
|
-
readonly
|
|
102
|
+
readonly project?: ProjectProps;
|
|
103
103
|
readonly environmentVariables?: { [key: string]: BuildEnvironmentVariable };
|
|
104
104
|
readonly stackName?: string;
|
|
105
105
|
readonly account?: string;
|
|
@@ -124,59 +124,53 @@ export class StackSegmentConstructed extends SegmentConstructed {
|
|
|
124
124
|
|
|
125
125
|
this.name = props.stack.stackName;
|
|
126
126
|
|
|
127
|
-
const buildArtifact = new Artifact();
|
|
127
|
+
const buildArtifact = props.project ? new Artifact() : undefined;
|
|
128
128
|
|
|
129
129
|
this.actions = [
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
new PublishAssetsAction(this, "PublishAssets", {
|
|
166
|
-
actionName: "PublishAssets",
|
|
167
|
-
runOrder: 2,
|
|
168
|
-
input: buildArtifact,
|
|
169
|
-
manifestPath: scope.buildDir,
|
|
170
|
-
}),
|
|
130
|
+
...(buildArtifact
|
|
131
|
+
? [
|
|
132
|
+
new CodeBuildAction({
|
|
133
|
+
actionName: "Build",
|
|
134
|
+
runOrder: 1,
|
|
135
|
+
input: props.input,
|
|
136
|
+
extraInputs: props.extraInputs,
|
|
137
|
+
outputs: [buildArtifact],
|
|
138
|
+
environmentVariables: props.environmentVariables,
|
|
139
|
+
project: new Project(this, "UpdateCodeBuild", {
|
|
140
|
+
...props.project,
|
|
141
|
+
buildSpec: props.project?.buildSpec
|
|
142
|
+
? mergeBuildSpecs(
|
|
143
|
+
props.project.buildSpec,
|
|
144
|
+
BuildSpec.fromObject({
|
|
145
|
+
artifacts: {
|
|
146
|
+
files: [path.join(scope.buildDir, "**/*")],
|
|
147
|
+
},
|
|
148
|
+
}),
|
|
149
|
+
)
|
|
150
|
+
: BuildSpec.fromObject({
|
|
151
|
+
artifacts: {
|
|
152
|
+
files: [path.join(scope.buildDir, "**/*")],
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
}),
|
|
156
|
+
}),
|
|
157
|
+
new PublishAssetsAction(this, "PublishAssets", {
|
|
158
|
+
actionName: "PublishAssets",
|
|
159
|
+
runOrder: 2,
|
|
160
|
+
input: buildArtifact,
|
|
161
|
+
manifestPath: scope.buildDir,
|
|
162
|
+
}),
|
|
163
|
+
]
|
|
164
|
+
: []),
|
|
171
165
|
new CloudFormationCreateReplaceChangeSetAction({
|
|
172
166
|
actionName: "PrepareChanges",
|
|
173
|
-
runOrder: 3,
|
|
167
|
+
runOrder: buildArtifact ? 3 : 1,
|
|
174
168
|
stackName: props.stackName ? props.stackName : props.stack.stackName,
|
|
175
169
|
account: props.account,
|
|
176
170
|
region: props.region,
|
|
177
171
|
changeSetName: `${props.stack.stackName}Changes`,
|
|
178
172
|
adminPermissions: true,
|
|
179
|
-
templatePath: buildArtifact.atPath(
|
|
173
|
+
templatePath: (buildArtifact ? buildArtifact : props.input).atPath(
|
|
180
174
|
path.join(scope.buildDir, props.stack.templateFile),
|
|
181
175
|
),
|
|
182
176
|
}),
|
|
@@ -184,13 +178,19 @@ export class StackSegmentConstructed extends SegmentConstructed {
|
|
|
184
178
|
? [
|
|
185
179
|
new ManualApprovalAction({
|
|
186
180
|
actionName: "ApproveChanges",
|
|
187
|
-
runOrder: 4,
|
|
181
|
+
runOrder: buildArtifact ? 4 : 2,
|
|
188
182
|
}),
|
|
189
183
|
]
|
|
190
184
|
: []),
|
|
191
185
|
new CloudFormationExecuteChangeSetAction({
|
|
192
186
|
actionName: "ExecuteChanges",
|
|
193
|
-
runOrder: props.manualApproval
|
|
187
|
+
runOrder: props.manualApproval
|
|
188
|
+
? buildArtifact
|
|
189
|
+
? 5
|
|
190
|
+
: 3
|
|
191
|
+
: buildArtifact
|
|
192
|
+
? 4
|
|
193
|
+
: 2,
|
|
194
194
|
stackName: props.stackName ? props.stackName : props.stack.stackName,
|
|
195
195
|
account: props.account,
|
|
196
196
|
region: props.region,
|