Skip to content

Commit 5ab2f34

Browse files
author
Tarun Belani
committed
Addressed review comments
1 parent 35903cb commit 5ab2f34

15 files changed

+926
-45
lines changed

packages/@aws-cdk/aws-imagebuilder-alpha/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ EC2 Image Builder supports AWS-managed components for common tasks, AWS Marketpl
4747
that you create. Components run during specific workflow phases: build and validate phases during the build stage, and
4848
test phase during the test stage.
4949

50-
#### Basic Usage
50+
#### Basic Component Usage
5151

5252
Create a component with the required properties: platform and component data.
5353

@@ -301,7 +301,7 @@ const infrastructureConfiguration = new imagebuilder.InfrastructureConfiguration
301301

302302
Workflows define the sequence of steps that Image Builder performs during image creation. There are three workflow types: BUILD (image building), TEST (testing images), and DISTRIBUTION (distributing container images).
303303

304-
#### Basic Usage
304+
#### Basic Workflow Usage
305305

306306
Create a workflow with the required properties: workflow type and workflow data.
307307

packages/@aws-cdk/aws-imagebuilder-alpha/awslint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"exclude": [
33
"props-no-arn-refs:@aws-cdk/aws-imagebuilder-alpha.InfrastructureConfigurationProps.ec2InstanceHostResourceGroupArn",
44
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.WorkflowAction",
5-
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.WorkflowConfiguration",
65
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.WorkflowOnFailure",
76
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.WorkflowParameterType",
87
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.WorkflowSchemaVersion"

packages/@aws-cdk/aws-imagebuilder-alpha/lib/component.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as s3 from 'aws-cdk-lib/aws-s3';
66
import * as s3assets from 'aws-cdk-lib/aws-s3-assets';
77
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
88
import { Construct } from 'constructs';
9-
import * as yaml from 'yaml';
9+
import { ImageBuilderData } from './imagebuilder-data';
1010
import { OSVersion, Platform } from './os-version';
1111

1212
const COMPONENT_SYMBOL = Symbol.for('@aws-cdk/aws-imagebuilder-alpha.Component');
@@ -640,7 +640,7 @@ export enum ComponentSchemaVersion {
640640
/**
641641
* Helper class for referencing and uploading component data
642642
*/
643-
export abstract class ComponentData {
643+
export abstract class ComponentData extends ImageBuilderData {
644644
/**
645645
* Uploads component data from a local file to S3 to use as the component data
646646
*
@@ -655,7 +655,7 @@ export abstract class ComponentData {
655655
path: string,
656656
options: s3assets.AssetOptions = {},
657657
): S3ComponentData {
658-
const asset = new s3assets.Asset(scope, id, { ...options, path });
658+
const asset = this.createAsset(scope, id, path, options);
659659
return new S3ComponentDataFromAsset(asset);
660660
}
661661

@@ -675,7 +675,7 @@ export abstract class ComponentData {
675675
* @param data An inline JSON object representing the component data
676676
*/
677677
public static fromJsonObject(data: { [key: string]: any }): ComponentData {
678-
const inlineData = yaml.stringify(data, { indent: 2 });
678+
const inlineData = this.createInlineYaml(data);
679679
return new InlineComponentData(inlineData);
680680
}
681681

@@ -721,20 +721,6 @@ export abstract class ComponentData {
721721
public static fromInline(data: string): ComponentData {
722722
return new InlineComponentData(data);
723723
}
724-
725-
/**
726-
* Indicates that the provided component data is an S3 reference
727-
*/
728-
abstract readonly isS3Reference: boolean;
729-
730-
/**
731-
* The resulting inline string or S3 URL which references the component data
732-
*/
733-
public readonly value: string;
734-
735-
protected constructor(value: string) {
736-
this.value = value;
737-
}
738724
}
739725

740726
/**
@@ -756,7 +742,7 @@ export abstract class S3ComponentData extends ComponentData {
756742
/**
757743
* Grant put permissions to the given grantee for the component data in S3
758744
*
759-
* @param grantee The principal
745+
* @param grantee - The principal
760746
*/
761747
public grantPut(grantee: iam.IGrantable): iam.Grant {
762748
return this.bucket.grantPut(grantee, this.key);
@@ -765,7 +751,7 @@ export abstract class S3ComponentData extends ComponentData {
765751
/**
766752
* Grant read permissions to the given grantee for the component data in S3
767753
*
768-
* @param grantee The principal
754+
* @param grantee - The principal
769755
*/
770756
public grantRead(grantee: iam.IGrantable): iam.Grant {
771757
return this.bucket.grantRead(grantee, this.key);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as s3assets from 'aws-cdk-lib/aws-s3-assets';
2+
import { Construct } from 'constructs';
3+
import * as yaml from 'yaml';
4+
5+
/**
6+
* Helper class for referencing and uploading ImageBuilder data (components, workflows, etc.)
7+
*
8+
* @internal
9+
*/
10+
export abstract class ImageBuilderData {
11+
/**
12+
* Protected method to create an S3 asset for use by derived classes
13+
*/
14+
protected static createAsset(
15+
scope: Construct,
16+
id: string,
17+
path: string,
18+
options: s3assets.AssetOptions = {},
19+
): s3assets.Asset {
20+
return new s3assets.Asset(scope, id, { ...options, path });
21+
}
22+
23+
/**
24+
* Protected method to create inline YAML data for use by derived classes
25+
*/
26+
protected static createInlineYaml(data: { [key: string]: any }): string {
27+
return yaml.stringify(data, { indent: 2 });
28+
}
29+
30+
/**
31+
* Indicates that the provided data is an S3 reference
32+
*/
33+
abstract readonly isS3Reference: boolean;
34+
35+
/**
36+
* The resulting inline string or S3 URL which references the data
37+
*/
38+
public readonly value: string;
39+
40+
protected constructor(value: string) {
41+
this.value = value;
42+
}
43+
}

packages/@aws-cdk/aws-imagebuilder-alpha/lib/workflow.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as kms from 'aws-cdk-lib/aws-kms';
55
import * as s3 from 'aws-cdk-lib/aws-s3';
66
import * as s3assets from 'aws-cdk-lib/aws-s3-assets';
77
import { Construct } from 'constructs';
8-
import * as yaml from 'yaml';
8+
import { ImageBuilderData } from './imagebuilder-data';
99

1010
const WORKFLOW_SYMBOL = Symbol.for('@aws-cdk/aws-imagebuilder-alpha.Workflow');
1111

@@ -145,7 +145,7 @@ export interface WorkflowAttributes {
145145

146146
/**
147147
* The version of the workflow
148-
* - x.x.x
148+
*
149149
* @default x.x.x
150150
*/
151151
readonly workflowVersion?: string;
@@ -308,7 +308,7 @@ export enum WorkflowType {
308308
/**
309309
* Helper class for referencing and uploading workflow data
310310
*/
311-
export abstract class WorkflowData {
311+
export abstract class WorkflowData extends ImageBuilderData {
312312
/**
313313
* Uploads workflow data from a local file to S3 to use as the workflow data
314314
*
@@ -322,8 +322,8 @@ export abstract class WorkflowData {
322322
id: string,
323323
path: string,
324324
options: s3assets.AssetOptions = {},
325-
): WorkflowData {
326-
const asset = new s3assets.Asset(scope, id, { ...options, path });
325+
): S3WorkflowData {
326+
const asset = this.createAsset(scope, id, path, options);
327327
return new S3WorkflowDataFromAsset(asset);
328328
}
329329

@@ -343,7 +343,7 @@ export abstract class WorkflowData {
343343
* @param data An inline JSON object representing the workflow data
344344
*/
345345
public static fromJsonObject(data: { [key: string]: any }): WorkflowData {
346-
const inlineData = yaml.stringify(data, { indent: 2 });
346+
const inlineData = this.createInlineYaml(data);
347347
return new InlineWorkflowData(inlineData);
348348
}
349349

@@ -355,20 +355,6 @@ export abstract class WorkflowData {
355355
public static fromInline(data: string): WorkflowData {
356356
return new InlineWorkflowData(data);
357357
}
358-
359-
/**
360-
* Indicates that the provided workflow data is an S3 reference
361-
*/
362-
abstract readonly isS3Reference: boolean;
363-
364-
/**
365-
* The resulting inline string or S3 URL which references the workflow data
366-
*/
367-
public readonly value: string;
368-
369-
protected constructor(value: string) {
370-
this.value = value;
371-
}
372358
}
373359

374360
/**
@@ -390,7 +376,7 @@ export abstract class S3WorkflowData extends WorkflowData {
390376
/**
391377
* Grant put permissions to the given grantee for the workflow data in S3
392378
*
393-
* @param grantee - The principal
379+
* @param grantee The principal
394380
*/
395381
public grantPut(grantee: iam.IGrantable): iam.Grant {
396382
return this.bucket.grantPut(grantee, this.key);
@@ -399,7 +385,7 @@ export abstract class S3WorkflowData extends WorkflowData {
399385
/**
400386
* Grant read permissions to the given grantee for the workflow data in S3
401387
*
402-
* @param grantee - The principal
388+
* @param grantee The principal
403389
*/
404390
public grantRead(grantee: iam.IGrantable): iam.Grant {
405391
return this.bucket.grantRead(grantee, this.key);

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.s3.workflow.js.snapshot/WorkflowTestDefaultTestDeployAssertAB988DED.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.s3.workflow.js.snapshot/WorkflowTestDefaultTestDeployAssertAB988DED.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.s3.workflow.js.snapshot/asset.6c2589532cc1551b2029f968e301fcbfc599120cb34cc72f8d59321b025ef594.yaml

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.s3.workflow.js.snapshot/aws-cdk-imagebuilder-workflow-s3-data.assets.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)