@flit/cdk-pipeline 1.5.0 → 2.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 +29 -3
- package/dist/artifact.js +2 -2
- package/dist/code-commit-source-segment.js +3 -3
- package/dist/code-star-source-segment.js +3 -3
- package/dist/git-hub-source-segment.js +3 -3
- package/dist/pipeline-segment.js +6 -6
- package/dist/pipeline.js +3 -3
- package/dist/publish-assets-action.js +2 -2
- package/dist/s3-source-segment.js +3 -3
- package/dist/segment.js +3 -3
- package/dist/source-segment.js +2 -2
- package/dist/stack-segment.js +13 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -14
- package/src/artifact.ts +18 -18
- package/src/code-commit-source-segment.ts +35 -35
- package/src/code-star-source-segment.ts +59 -59
- package/src/git-hub-source-segment.ts +55 -55
- package/src/pipeline-segment.ts +138 -138
- package/src/pipeline.ts +1 -1
- package/src/publish-assets-action.ts +102 -102
- package/src/s3-source-segment.ts +36 -36
- package/src/segment.ts +22 -22
- package/src/source-segment.ts +3 -3
- package/src/stack-segment.ts +70 -60
package/src/segment.ts
CHANGED
|
@@ -6,32 +6,32 @@ import { Artifact } from "./artifact";
|
|
|
6
6
|
import { Pipeline } from "./pipeline";
|
|
7
7
|
|
|
8
8
|
export interface SegmentProps {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
readonly input?: Artifact | Artifact[];
|
|
10
|
+
readonly output?: Artifact | Artifact[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export abstract class Segment {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
readonly isSource: boolean = false;
|
|
15
|
+
readonly isPipeline: boolean = false;
|
|
16
|
+
readonly dependencies?: Stack[];
|
|
17
|
+
readonly inputs: Artifact[] = [];
|
|
18
|
+
readonly outputs: Artifact[] = [];
|
|
19
|
+
constructor(props: SegmentProps) {
|
|
20
|
+
if (props.input) {
|
|
21
|
+
this.inputs = Array.isArray(props.input) ? props.input : [props.input];
|
|
22
|
+
this.inputs.forEach((artifact) => artifact.consume(this), this);
|
|
23
|
+
}
|
|
24
|
+
if (props.output) {
|
|
25
|
+
this.outputs = Array.isArray(props.output)
|
|
26
|
+
? props.output
|
|
27
|
+
: [props.output];
|
|
28
|
+
this.outputs.forEach((artifact) => artifact.produce(this), this);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
abstract construct(scope: Pipeline): SegmentConstructed;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export abstract class SegmentConstructed extends Construct {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
readonly name: string = "";
|
|
36
|
+
readonly actions: IAction[] = [];
|
|
37
37
|
}
|
package/src/source-segment.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { Artifact } from "./artifact";
|
|
|
2
2
|
import { Segment } from "./segment";
|
|
3
3
|
|
|
4
4
|
export interface SourceSegmentProps {
|
|
5
|
-
|
|
5
|
+
readonly output: Artifact;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export abstract class SourceSegment extends Segment {
|
|
9
|
-
|
|
9
|
+
readonly isSource = true;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function isSource(item: Segment): item is SourceSegment {
|
|
13
|
-
|
|
13
|
+
return item.isSource;
|
|
14
14
|
}
|
package/src/stack-segment.ts
CHANGED
|
@@ -86,7 +86,7 @@ export class StackSegment extends Segment {
|
|
|
86
86
|
construct(scope: Pipeline): SegmentConstructed {
|
|
87
87
|
return new StackSegmentConstructed(
|
|
88
88
|
scope,
|
|
89
|
-
`Deploy${this.props.stack.
|
|
89
|
+
`Deploy${this.props.stack.node.id}`,
|
|
90
90
|
{
|
|
91
91
|
...this.props,
|
|
92
92
|
input: this.inputs[0],
|
|
@@ -120,7 +120,7 @@ export class StackSegmentConstructed extends SegmentConstructed {
|
|
|
120
120
|
) {
|
|
121
121
|
super(scope, id);
|
|
122
122
|
|
|
123
|
-
this.name = props.stack.
|
|
123
|
+
this.name = props.stack.node.id;
|
|
124
124
|
|
|
125
125
|
const buildArtifact = props.project
|
|
126
126
|
? props.buildOutput || new Artifact()
|
|
@@ -130,67 +130,77 @@ export class StackSegmentConstructed extends SegmentConstructed {
|
|
|
130
130
|
...props.project,
|
|
131
131
|
buildSpec: props.project?.buildSpec
|
|
132
132
|
? mergeBuildSpecs(
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
props.project.buildSpec,
|
|
134
|
+
BuildSpec.fromObject({
|
|
135
|
+
artifacts: {
|
|
136
|
+
files: [path.join(scope.buildDir, "**/*")],
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
)
|
|
140
|
+
: BuildSpec.fromObject({
|
|
135
141
|
artifacts: {
|
|
136
142
|
files: [path.join(scope.buildDir, "**/*")],
|
|
137
143
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
: BuildSpec.fromObject({
|
|
141
|
-
artifacts: {
|
|
142
|
-
files: [path.join(scope.buildDir, "**/*")],
|
|
143
|
-
},
|
|
144
|
-
}),
|
|
145
|
-
})
|
|
144
|
+
}),
|
|
145
|
+
});
|
|
146
146
|
|
|
147
|
-
Object.entries(
|
|
147
|
+
Object.entries(
|
|
148
|
+
props.project?.environment?.environmentVariables || [],
|
|
149
|
+
).forEach(([, v]) => {
|
|
148
150
|
switch (v.type) {
|
|
149
151
|
case BuildEnvironmentVariableType.PARAMETER_STORE:
|
|
150
|
-
codeBuildProject.addToRolePolicy(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
codeBuildProject.addToRolePolicy(
|
|
153
|
+
new PolicyStatement({
|
|
154
|
+
actions: [
|
|
155
|
+
"ssm:GetParameter",
|
|
156
|
+
"ssm:GetParameters",
|
|
157
|
+
"ssm:GetParametersByPath",
|
|
158
|
+
],
|
|
159
|
+
resources: [
|
|
160
|
+
`arn:aws:ssm:*:${Stack.of(this).account}:parameter/${v.value}`,
|
|
161
|
+
],
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
160
164
|
break;
|
|
161
165
|
case BuildEnvironmentVariableType.SECRETS_MANAGER:
|
|
162
|
-
codeBuildProject.addToRolePolicy(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
codeBuildProject.addToRolePolicy(
|
|
167
|
+
new PolicyStatement({
|
|
168
|
+
actions: [
|
|
169
|
+
"secretsmanager:GetSecretValue",
|
|
170
|
+
"secretsmanager:DescribeSecret",
|
|
171
|
+
],
|
|
172
|
+
resources: [
|
|
173
|
+
(v.value as string).startsWith("arn:")
|
|
174
|
+
? v.value.split(":").slice(0, 7).join(":")
|
|
175
|
+
: `arn:aws:secretsmanager:*:${
|
|
176
|
+
Stack.of(this).account
|
|
177
|
+
}:secret:${v.value}-*`,
|
|
178
|
+
],
|
|
179
|
+
}),
|
|
180
|
+
);
|
|
171
181
|
break;
|
|
172
182
|
}
|
|
173
|
-
})
|
|
183
|
+
});
|
|
174
184
|
|
|
175
185
|
this.actions = [
|
|
176
186
|
...(buildArtifact
|
|
177
187
|
? [
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
new CodeBuildAction({
|
|
189
|
+
actionName: `${this.name}Build`,
|
|
190
|
+
runOrder: 1,
|
|
191
|
+
input: props.input,
|
|
192
|
+
extraInputs: props.extraInputs,
|
|
193
|
+
outputs: [buildArtifact],
|
|
194
|
+
environmentVariables: props.environmentVariables,
|
|
195
|
+
project: codeBuildProject,
|
|
196
|
+
}),
|
|
197
|
+
new PublishAssetsAction(this, "PublishAssets", {
|
|
198
|
+
actionName: `${this.name}PublishAssets`,
|
|
199
|
+
runOrder: 2,
|
|
200
|
+
input: buildArtifact,
|
|
201
|
+
manifestPath: scope.buildDir,
|
|
202
|
+
}),
|
|
203
|
+
]
|
|
194
204
|
: []),
|
|
195
205
|
new CloudFormationCreateReplaceChangeSetAction({
|
|
196
206
|
actionName: `${this.name}PrepareChanges`,
|
|
@@ -198,7 +208,7 @@ export class StackSegmentConstructed extends SegmentConstructed {
|
|
|
198
208
|
stackName: props.stackName ? props.stackName : props.stack.stackName,
|
|
199
209
|
account: props.stack.account,
|
|
200
210
|
region: props.stack.region,
|
|
201
|
-
changeSetName: `${
|
|
211
|
+
changeSetName: `${this.name}Changes`,
|
|
202
212
|
adminPermissions: true,
|
|
203
213
|
templatePath: (buildArtifact ? buildArtifact : props.input).atPath(
|
|
204
214
|
path.join(scope.buildDir, props.stack.templateFile),
|
|
@@ -206,11 +216,11 @@ export class StackSegmentConstructed extends SegmentConstructed {
|
|
|
206
216
|
}),
|
|
207
217
|
...(props.manualApproval
|
|
208
218
|
? [
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
219
|
+
new ManualApprovalAction({
|
|
220
|
+
actionName: `${this.name}ApproveChanges`,
|
|
221
|
+
runOrder: buildArtifact ? 4 : 2,
|
|
222
|
+
}),
|
|
223
|
+
]
|
|
214
224
|
: []),
|
|
215
225
|
new CloudFormationExecuteChangeSetAction({
|
|
216
226
|
actionName: `${this.name}ExecuteChanges`,
|
|
@@ -219,18 +229,18 @@ export class StackSegmentConstructed extends SegmentConstructed {
|
|
|
219
229
|
? 5
|
|
220
230
|
: 3
|
|
221
231
|
: buildArtifact
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
? 4
|
|
233
|
+
: 2,
|
|
224
234
|
stackName: props.stackName ? props.stackName : props.stack.stackName,
|
|
225
235
|
account: props.stack.account,
|
|
226
236
|
region: props.stack.region,
|
|
227
|
-
changeSetName: `${
|
|
237
|
+
changeSetName: `${this.name}Changes`,
|
|
228
238
|
output: props.stackOutput,
|
|
229
239
|
outputFileName: props.outputFileName
|
|
230
240
|
? props.outputFileName
|
|
231
241
|
: props.stackOutput
|
|
232
|
-
|
|
233
|
-
|
|
242
|
+
? "artifact.json"
|
|
243
|
+
: undefined,
|
|
234
244
|
}),
|
|
235
245
|
];
|
|
236
246
|
}
|