@flit/cdk-pipeline 1.4.4 → 2.0.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 +202 -37
- 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 +4 -4
- package/dist/pipeline.js +4 -4
- 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 +50 -18
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +97 -99
- 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 +103 -103
- 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 +214 -173
|
@@ -1,123 +1,123 @@
|
|
|
1
1
|
import { Stack } from "aws-cdk-lib";
|
|
2
2
|
import { Construct } from "constructs";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
ActionBindOptions,
|
|
5
|
+
ActionConfig,
|
|
6
|
+
ActionProperties,
|
|
7
|
+
Artifact,
|
|
8
|
+
IAction,
|
|
9
|
+
IStage,
|
|
10
10
|
} from "aws-cdk-lib/aws-codepipeline";
|
|
11
11
|
import { BuildSpec, LinuxBuildImage, Project } from "aws-cdk-lib/aws-codebuild";
|
|
12
12
|
import { CodeBuildAction } from "aws-cdk-lib/aws-codepipeline-actions";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
AccountPrincipal,
|
|
15
|
+
CompositePrincipal,
|
|
16
|
+
PolicyDocument,
|
|
17
|
+
PolicyStatement,
|
|
18
|
+
Role,
|
|
19
|
+
ServicePrincipal,
|
|
20
20
|
} from "aws-cdk-lib/aws-iam";
|
|
21
21
|
import { IRuleTarget, RuleProps, Rule } from "aws-cdk-lib/aws-events";
|
|
22
22
|
import * as path from "path";
|
|
23
23
|
|
|
24
24
|
export interface PublishAssetsActionProps {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
readonly actionName: string;
|
|
26
|
+
readonly input: Artifact;
|
|
27
|
+
readonly manifestPath: string;
|
|
28
|
+
readonly runOrder?: number;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export class PublishAssetsAction extends Construct implements IAction {
|
|
32
|
-
|
|
32
|
+
public readonly actionProperties: ActionProperties;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
bound(
|
|
35
|
+
scope: Construct,
|
|
36
|
+
stage: IStage,
|
|
37
|
+
options: ActionBindOptions,
|
|
38
|
+
): ActionConfig {
|
|
39
|
+
throw new Error(`Method not implemented.${!scope && !stage! && options}`);
|
|
40
|
+
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
bind(
|
|
43
|
+
scope: Construct,
|
|
44
|
+
stage: IStage,
|
|
45
|
+
options: ActionBindOptions,
|
|
46
|
+
): ActionConfig {
|
|
47
|
+
throw new Error(`Method not implemented.${!scope && !stage! && options}`);
|
|
48
|
+
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
onStateChange(
|
|
51
|
+
name: string,
|
|
52
|
+
target?: IRuleTarget | undefined,
|
|
53
|
+
options?: RuleProps | undefined,
|
|
54
|
+
): Rule {
|
|
55
|
+
throw new Error(`Method not implemented.${!name && !target! && options}`);
|
|
56
|
+
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
58
|
+
constructor(scope: Construct, id: string, props: PublishAssetsActionProps) {
|
|
59
|
+
super(scope, id);
|
|
60
|
+
const codeBuild = new CodeBuildAction({
|
|
61
|
+
...props,
|
|
62
|
+
input: props.input,
|
|
63
|
+
project: new Project(this, id, {
|
|
64
|
+
environment: {
|
|
65
|
+
buildImage: LinuxBuildImage.AMAZON_LINUX_2_5,
|
|
66
|
+
},
|
|
67
|
+
role: new Role(this, "UpdatePipelineCodeCuildRole", {
|
|
68
|
+
assumedBy: new CompositePrincipal(
|
|
69
|
+
new ServicePrincipal("codebuild.amazonaws.com"),
|
|
70
|
+
new AccountPrincipal(Stack.of(this).account),
|
|
71
|
+
),
|
|
72
|
+
inlinePolicies: {
|
|
73
|
+
selfMutation: new PolicyDocument({
|
|
74
|
+
statements: [
|
|
75
|
+
new PolicyStatement({
|
|
76
|
+
actions: ["sts:AssumeRole"],
|
|
77
|
+
resources: [`arn:*:iam::${Stack.of(this).account}:role/*`],
|
|
78
|
+
conditions: {
|
|
79
|
+
"ForAnyValue:StringEquals": {
|
|
80
|
+
"iam:ResourceTag/aws-cdk:bootstrap-role": [
|
|
81
|
+
"image-publishing",
|
|
82
|
+
"file-publishing",
|
|
83
|
+
"deploy",
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
buildSpec: BuildSpec.fromObject({
|
|
93
|
+
version: "0.2",
|
|
94
|
+
phases: {
|
|
95
|
+
install: {
|
|
96
|
+
"runtime-versions": {
|
|
97
|
+
nodejs: "latest",
|
|
98
|
+
},
|
|
99
|
+
commands: ["npm i -g @flit/publish-cdk-assets@latest"],
|
|
100
|
+
},
|
|
101
|
+
build: {
|
|
102
|
+
commands: `pca ${
|
|
103
|
+
props.manifestPath ? path.normalize(props.manifestPath) : "."
|
|
104
|
+
}`,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
111
|
+
this.actionProperties = codeBuild.actionProperties;
|
|
112
|
+
this.bind = (
|
|
113
|
+
scope: Construct,
|
|
114
|
+
stage: IStage,
|
|
115
|
+
options: ActionBindOptions,
|
|
116
|
+
): ActionConfig => codeBuild.bind(scope, stage, options);
|
|
117
|
+
this.onStateChange = (
|
|
118
|
+
name: string,
|
|
119
|
+
target?: IRuleTarget,
|
|
120
|
+
options?: RuleProps,
|
|
121
|
+
): Rule => codeBuild.onStateChange(name, target, options);
|
|
122
|
+
}
|
|
123
123
|
}
|
package/src/s3-source-segment.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IAction } from "aws-cdk-lib/aws-codepipeline";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
S3SourceAction,
|
|
4
|
+
S3Trigger,
|
|
5
5
|
} from "aws-cdk-lib/aws-codepipeline-actions";
|
|
6
6
|
import { SecretValue } from "aws-cdk-lib";
|
|
7
7
|
import { IBucket } from "aws-cdk-lib/aws-s3";
|
|
@@ -12,51 +12,51 @@ import { SegmentConstructed } from "./segment";
|
|
|
12
12
|
import { SourceSegment, SourceSegmentProps } from "./source-segment";
|
|
13
13
|
|
|
14
14
|
export interface S3SourceSegmentProps extends SourceSegmentProps {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
readonly oauthToken: SecretValue;
|
|
16
|
+
readonly bucket: IBucket;
|
|
17
|
+
readonly bucketKey: string;
|
|
18
|
+
readonly trigger?: S3Trigger;
|
|
19
|
+
readonly variablesNamespace?: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @category Segments
|
|
24
24
|
*/
|
|
25
25
|
export class S3SourceSegment extends SourceSegment {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
private props: S3SourceSegmentProps;
|
|
27
|
+
constructor(props: S3SourceSegmentProps) {
|
|
28
|
+
super(props);
|
|
29
|
+
this.props = props;
|
|
30
|
+
}
|
|
31
|
+
construct(scope: Pipeline): SegmentConstructed {
|
|
32
|
+
const name = `${this.props.bucket}-${this.props.bucketKey}`;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
return new S3SourceSegmentConstructed(scope, name, {
|
|
35
|
+
...this.props,
|
|
36
|
+
actionName: name,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export interface S3SourceSegmentConstructedProps {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
readonly output: Artifact;
|
|
43
|
+
readonly actionName: string;
|
|
44
|
+
readonly bucket: IBucket;
|
|
45
|
+
readonly bucketKey: string;
|
|
46
|
+
readonly trigger?: S3Trigger;
|
|
47
|
+
readonly variablesNamespace?: string;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export class S3SourceSegmentConstructed extends SegmentConstructed {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly actions: IAction[];
|
|
53
|
+
constructor(
|
|
54
|
+
scope: Pipeline,
|
|
55
|
+
id: string,
|
|
56
|
+
props: S3SourceSegmentConstructedProps,
|
|
57
|
+
) {
|
|
58
|
+
super(scope, id);
|
|
59
|
+
this.name = "Source";
|
|
60
|
+
this.actions = [new S3SourceAction(props)];
|
|
61
|
+
}
|
|
62
62
|
}
|
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
|
}
|