@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.
@@ -1,123 +1,123 @@
1
1
  import { Stack } from "aws-cdk-lib";
2
2
  import { Construct } from "constructs";
3
3
  import {
4
- ActionBindOptions,
5
- ActionConfig,
6
- ActionProperties,
7
- Artifact,
8
- IAction,
9
- IStage,
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
- AccountPrincipal,
15
- CompositePrincipal,
16
- PolicyDocument,
17
- PolicyStatement,
18
- Role,
19
- ServicePrincipal,
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
- readonly actionName: string;
26
- readonly input: Artifact;
27
- readonly manifestPath: string;
28
- readonly runOrder?: number;
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
- public readonly actionProperties: ActionProperties;
32
+ public readonly actionProperties: ActionProperties;
33
33
 
34
- bound(
35
- scope: Construct,
36
- stage: IStage,
37
- options: ActionBindOptions,
38
- ): ActionConfig {
39
- throw new Error(`Method not implemented.${!scope && !stage! && options}`);
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
- bind(
43
- scope: Construct,
44
- stage: IStage,
45
- options: ActionBindOptions,
46
- ): ActionConfig {
47
- throw new Error(`Method not implemented.${!scope && !stage! && options}`);
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
- 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
- }
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
- 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
- });
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
- 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
- }
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
  }
@@ -1,7 +1,7 @@
1
1
  import { IAction } from "aws-cdk-lib/aws-codepipeline";
2
2
  import {
3
- S3SourceAction,
4
- S3Trigger,
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
- readonly oauthToken: SecretValue;
16
- readonly bucket: IBucket;
17
- readonly bucketKey: string;
18
- readonly trigger?: S3Trigger;
19
- readonly variablesNamespace?: string;
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
- 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}`;
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
- return new S3SourceSegmentConstructed(scope, name, {
35
- ...this.props,
36
- actionName: name,
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
- readonly output: Artifact;
43
- readonly actionName: string;
44
- readonly bucket: IBucket;
45
- readonly bucketKey: string;
46
- readonly trigger?: S3Trigger;
47
- readonly variablesNamespace?: string;
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
- 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
- }
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
- readonly input?: Artifact | Artifact[];
10
- readonly output?: Artifact | Artifact[];
9
+ readonly input?: Artifact | Artifact[];
10
+ readonly output?: Artifact | Artifact[];
11
11
  }
12
12
 
13
13
  export abstract class Segment {
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;
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
- readonly name: string = "";
36
- readonly actions: IAction[] = [];
35
+ readonly name: string = "";
36
+ readonly actions: IAction[] = [];
37
37
  }
@@ -2,13 +2,13 @@ import { Artifact } from "./artifact";
2
2
  import { Segment } from "./segment";
3
3
 
4
4
  export interface SourceSegmentProps {
5
- readonly output: Artifact;
5
+ readonly output: Artifact;
6
6
  }
7
7
 
8
8
  export abstract class SourceSegment extends Segment {
9
- readonly isSource = true;
9
+ readonly isSource = true;
10
10
  }
11
11
 
12
12
  export function isSource(item: Segment): item is SourceSegment {
13
- return item.isSource;
13
+ return item.isSource;
14
14
  }