Skip to content

Commit a9f8153

Browse files
author
Tarun Belani
committed
Addressed review comments
1 parent 1859ce1 commit a9f8153

File tree

3 files changed

+64
-81
lines changed

3 files changed

+64
-81
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
export * from './component';
44
export * from './distribution-configuration';
55
export * from './infrastructure-configuration';
6+
export * from './workflow';
67

78
export * from './os-version';
8-
export * from './workflow';

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

Lines changed: 63 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export interface WorkflowAttributes {
125125
* The ARN of the workflow
126126
*
127127
* @default - the ARN is automatically constructed if a workflowName and workflowType is provided, otherwise a
128-
* workflowArn is required
128+
* workflowArn is required
129129
*/
130130
readonly workflowArn?: string;
131131

@@ -170,6 +170,12 @@ export interface AwsManagedWorkflowAttributes {
170170
* The action for a step within the workflow document
171171
*/
172172
export enum WorkflowAction {
173+
/**
174+
* Applies customizations and configurations to the input AMIs, such as publishing the AMI to SSM Parameter Store,
175+
* or creating launch template versions with the AMI IDs provided in the input
176+
*/
177+
APPLY_IMAGE_CONFIGURATIONS = 'ApplyImageConfigurations',
178+
173179
/**
174180
* The BootstrapInstanceForContainer action runs a service script to bootstrap the instance with minimum requirements
175181
* to run container workflows
@@ -192,6 +198,12 @@ export enum WorkflowAction {
192198
*/
193199
CREATE_IMAGE = 'CreateImage',
194200

201+
/**
202+
* The DistributeImage action copies an AMI using the image's distribution configuration, or using the distribution
203+
* settings in the step input
204+
*/
205+
DISTRIBUTE_IMAGE = 'DistributeImage',
206+
195207
/**
196208
* The ExecuteComponents action runs components that are specified in the recipe for the current image being built
197209
*/
@@ -209,6 +221,11 @@ export enum WorkflowAction {
209221
*/
210222
LAUNCH_INSTANCE = 'LaunchInstance',
211223

224+
/**
225+
* Applies attribute updates to the provided set of distributed images, such as launch permission updates
226+
*/
227+
MODIFY_IMAGE_ATTRIBUTES = 'ModifyImageAttributes',
228+
212229
/**
213230
* The RunCommand action runs a command document against the provided instance
214231
*/
@@ -316,6 +333,27 @@ export enum WorkflowType {
316333
DISTRIBUTION = 'DISTRIBUTION',
317334
}
318335

336+
/**
337+
* The rendered workflow data value, for use in CloudFormation.
338+
* - For inline workflows, data is the workflow text
339+
* - For S3-backed workflows, uri is the S3 URL
340+
*/
341+
export interface WorkflowDataConfig {
342+
/**
343+
* The rendered workflow data, for use in CloudFormation
344+
*
345+
* @default - none if uri is set
346+
*/
347+
readonly data?: string;
348+
349+
/**
350+
* The rendered workflow data URI, for use in CloudFormation
351+
*
352+
* @default - none if data is set
353+
*/
354+
readonly uri?: string;
355+
}
356+
319357
/**
320358
* Helper class for referencing and uploading workflow data
321359
*/
@@ -368,36 +406,34 @@ export abstract class WorkflowData {
368406
}
369407

370408
/**
371-
* Indicates that the provided workflow data is an S3 reference
409+
* The rendered workflow data value, for use in CloudFormation.
410+
* - For inline workflows, data is the workflow text
411+
* - For S3-backed workflows, uri is the S3 URL
372412
*/
373-
abstract readonly isS3Reference: boolean;
374-
375-
/**
376-
* The resulting inline string or S3 URL which references the workflow data
377-
*/
378-
public readonly value: string;
379-
380-
protected constructor(value: string) {
381-
this.value = value;
382-
}
413+
abstract render(): WorkflowDataConfig;
383414
}
384415

385416
/**
386417
* Helper class for S3-based workflow data references, containing additional permission grant methods on the S3 object
387418
*/
388419
export abstract class S3WorkflowData extends WorkflowData {
389-
public readonly isS3Reference = true;
390-
391420
protected readonly bucket: s3.IBucket;
392421
protected readonly key: string;
393422

394423
protected constructor(bucket: s3.IBucket, key: string) {
395-
super(bucket.s3UrlForObject(key));
424+
super();
396425

397426
this.bucket = bucket;
398427
this.key = key;
399428
}
400429

430+
/**
431+
* The rendered workflow data text, for use in CloudFormation
432+
*/
433+
public render(): WorkflowDataConfig {
434+
return { uri: this.bucket.s3UrlForObject(this.key) };
435+
}
436+
401437
/**
402438
* Grant put permissions to the given grantee for the workflow data in S3
403439
*
@@ -418,10 +454,19 @@ export abstract class S3WorkflowData extends WorkflowData {
418454
}
419455

420456
class InlineWorkflowData extends WorkflowData {
421-
public readonly isS3Reference = false;
457+
protected readonly data: string;
422458

423459
public constructor(data: string) {
424-
super(data);
460+
super();
461+
462+
this.data = data;
463+
}
464+
465+
/**
466+
* The rendered workflow data text, for use in CloudFormation
467+
*/
468+
public render(): WorkflowDataConfig {
469+
return { data: this.data };
425470
}
426471
}
427472

@@ -437,55 +482,6 @@ class S3WorkflowDataFromAsset extends S3WorkflowData {
437482
}
438483
}
439484

440-
/**
441-
* The parameter value for a workflow parameter
442-
*/
443-
export class WorkflowParameterValue {
444-
/**
445-
* The value of the parameter as a boolean
446-
*
447-
* @param value The boolean value of the parameter
448-
*/
449-
public static fromBoolean(value: boolean): WorkflowParameterValue {
450-
return new WorkflowParameterValue([value.toString()]);
451-
}
452-
453-
/**
454-
* The value of the parameter as an integer
455-
*
456-
* @param value The integer value of the parameter
457-
*/
458-
public static fromInteger(value: number): WorkflowParameterValue {
459-
return new WorkflowParameterValue([value.toString()]);
460-
}
461-
462-
/**
463-
* The value of the parameter as a string
464-
* @param value The string value of the parameter
465-
*/
466-
public static fromString(value: string): WorkflowParameterValue {
467-
return new WorkflowParameterValue([value]);
468-
}
469-
470-
/**
471-
* The value of the parameter as a string list
472-
*
473-
* @param values The string list value of the parameter
474-
*/
475-
public static fromStringList(values: string[]): WorkflowParameterValue {
476-
return new WorkflowParameterValue(values);
477-
}
478-
479-
/**
480-
* The rendered parameter value
481-
*/
482-
public readonly value: string[];
483-
484-
protected constructor(value: string[]) {
485-
this.value = value;
486-
}
487-
}
488-
489485
/**
490486
* Helper class for working with AWS-managed workflows
491487
*/
@@ -779,7 +775,7 @@ export class Workflow extends WorkflowBase {
779775
description: props.description,
780776
kmsKeyId: props.kmsKey?.keyArn,
781777
tags: props.tags,
782-
...(props.data.isS3Reference ? { uri: props.data.value } : { data: props.data.value }),
778+
...props.data.render(),
783779
});
784780

785781
this.workflowName = this.getResourceNameAttribute(workflow.getAtt('Name').toString());

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
WorkflowData,
1212
WorkflowOnFailure,
1313
WorkflowParameterType,
14-
WorkflowParameterValue,
1514
WorkflowSchemaVersion,
1615
WorkflowType,
1716
} from '../lib';
@@ -512,18 +511,6 @@ steps:
512511
});
513512
});
514513

515-
test('workflow parameter values render as expected', () => {
516-
const booleanValue = WorkflowParameterValue.fromBoolean(true);
517-
const integerValue = WorkflowParameterValue.fromInteger(42);
518-
const stringValue = WorkflowParameterValue.fromString('test-value');
519-
const stringListValue = WorkflowParameterValue.fromStringList(['value1', 'value2', 'value3']);
520-
521-
expect(booleanValue.value).toEqual(['true']);
522-
expect(integerValue.value).toEqual(['42']);
523-
expect(stringValue.value).toEqual(['test-value']);
524-
expect(stringListValue.value).toEqual(['value1', 'value2', 'value3']);
525-
});
526-
527514
test('grants read access to IAM roles', () => {
528515
const workflow = new Workflow(stack, 'Workflow', {
529516
workflowType: WorkflowType.BUILD,

0 commit comments

Comments
 (0)