Skip to content

Commit

Permalink
fix: write only user defined step outputs (#53)
Browse files Browse the repository at this point in the history
Document creation fails when synthesizing documents with step outputs that match the documentation.  Only user defined outputs should be used for document creation.
  • Loading branch information
jcgould2021 authored Nov 15, 2022
1 parent d25df44 commit f6be096
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 95 deletions.
198 changes: 198 additions & 0 deletions API.md

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions src/parent-steps/automation-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export abstract class AutomationStep extends Step implements IAutomationComponen
ssmDef.set('action', this.action);
ssmDef.set('inputs', inputs);

const formattedOutputs = this.listOutputs().map(output => this.formatOutput(output));
if (this.listOutputs().length > 0) {
if (this.listUserOutputs().length > 0) {
const formattedOutputs = this.listUserOutputs().map(this.formatOutput);
ssmDef.set('outputs', formattedOutputs);
}
if (this.isEnd) {
Expand Down Expand Up @@ -140,4 +140,15 @@ export abstract class AutomationStep extends Step implements IAutomationComponen
return Object.assign({}, ...this.listOutputs()
.map(out => ({ [out.name]: new StringVariable(`${this.name}.${out.name}`) })));
}

/**
* Lists the outputs defined by the user for this step.
*/
public listUserOutputs(): Output[] {
return [];
}

public listOutputs(): Output[] {
return this.listUserOutputs();
}
}
2 changes: 1 addition & 1 deletion src/parent-steps/automation/aws-api-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class AwsApiStep extends AutomationStep {
/**
* @returns Outputs as specified in params
*/
public listOutputs(): Output[] {
public listUserOutputs(): Output[] {
return this.outputs;
}

Expand Down
2 changes: 1 addition & 1 deletion src/parent-steps/automation/execute-script-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class ExecuteScriptStep extends AutomationStep {
}
}

public listOutputs(): Output[] {
public listUserOutputs(): Output[] {
return this.outputs;
}

Expand Down
9 changes: 0 additions & 9 deletions test/parent-steps/automation/copy-image-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,6 @@ describe('CopyImageStep', () => {
ClientToken: 'token',
},
name: 'id2',
outputs: [{
Type: 'String',
Name: 'ImageId',
Selector: '$.ImageId',
}, {
Type: 'String',
Name: 'ImageState',
Selector: '$.ImageState',
}],
});
});
});
Expand Down
9 changes: 0 additions & 9 deletions test/parent-steps/automation/create-image-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,6 @@ describe('CreateImageStep', () => {
BlockDeviceMappings: { a: 1 },
},
name: 'id2',
outputs: [{
Type: 'String',
Name: 'ImageId',
Selector: '$.ImageId',
}, {
Type: 'String',
Name: 'ImageState',
Selector: '$.ImageState',
}],
});
});
});
Expand Down
13 changes: 0 additions & 13 deletions test/parent-steps/automation/create-stack-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,6 @@ describe('CreateStackStep', () => {
TimeoutInMinutes: 5,
},
name: 'createStack',
outputs: [{
Type: 'String',
Name: 'StackId',
Selector: '$.StackId',
}, {
Type: 'String',
Name: 'StackStatus',
Selector: '$.StackStatus',
}, {
Type: 'String',
Name: 'StackStatusReason',
Selector: '$.StackStatusReason',
}],
});
});
});
Expand Down
17 changes: 0 additions & 17 deletions test/parent-steps/automation/invoke-lambda-function-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,6 @@ describe('InvokeLambdaFunctionStep', () => {
Payload: { a: 1 },
},
name: 'id2',
outputs: [{
Type: 'Integer',
Name: 'StatusCode',
Selector: '$.StatusCode',
}, {
Type: 'String',
Name: 'FunctionError',
Selector: '$.FunctionError',
}, {
Type: 'String',
Name: 'LogResult',
Selector: '$.LogResult',
}, {
Type: 'String',
Name: 'Payload',
Selector: '$.Payload',
}],
});
});
});
Expand Down
9 changes: 0 additions & 9 deletions test/parent-steps/automation/invoke-webhook-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ describe('InvokeWebhookStep', () => {
Body: 'body',
},
name: 'id2',
outputs: [{
Type: 'String',
Name: 'Response',
Selector: '$.Response',
}, {
Type: 'Integer',
Name: 'ResponseCode',
Selector: '$.ResponseCode',
}],
});
});
});
Expand Down
22 changes: 0 additions & 22 deletions test/parent-steps/automation/run-command-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,6 @@ describe('RunCommandStep', () => {
MaxErrors: 5,
},
name: 'runCommand',
outputs: [
{
Name: 'CommandId',
Selector: '$.CommandId',
Type: 'String',
},
{
Name: 'Status',
Selector: '$.Status',
Type: 'String',
},
{
Name: 'ResponseCode',
Selector: '$.ResponseCode',
Type: 'Integer',
},
{
Name: 'Output',
Selector: '$.Output',
Type: 'String',
},
],
});
});
});
Expand Down
12 changes: 0 additions & 12 deletions test/parent-steps/automation/run-instance-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,6 @@ describe('RunInstanceStep', function() {
UserData: 'string',
},
name: 'id2',
outputs: [
{
Name: 'InstanceIds',
Selector: '$.InstanceIds',
Type: 'StringList',
},
{
Name: 'InstanceStates',
Selector: '$.InstanceStates',
Type: 'StringList',
},
],
});
});
});
Expand Down

0 comments on commit f6be096

Please sign in to comment.