Skip to content

Commit

Permalink
fix: use InputPayload for ssm entry of aws:invokeLambdaFunction (#58)
Browse files Browse the repository at this point in the history
Fixes #57 
aws:invokeLambdaFunction allows defining a JSON string input Payload or a StringMap version InputPayload.  CDK was incorrectly setting the user's StringMap to the Payload variable instead of InputPayload.
  • Loading branch information
jcgould2021 authored Mar 1, 2023
1 parent 9818ba2 commit 613f095
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
7 changes: 0 additions & 7 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -9294,7 +9294,6 @@ new InvokeLambdaFunctionStep(scope: Construct, id: string, props: InvokeLambdaFu
| <code><a href="#@cdklabs/cdk-ssm-documents.InvokeLambdaFunctionStep.addToDocument">addToDocument</a></code> | *No description.* |
| <code><a href="#@cdklabs/cdk-ssm-documents.InvokeLambdaFunctionStep.listUserOutputs">listUserOutputs</a></code> | Lists the outputs defined by the user for this step. |
| <code><a href="#@cdklabs/cdk-ssm-documents.InvokeLambdaFunctionStep.variables">variables</a></code> | *No description.* |
| <code><a href="#@cdklabs/cdk-ssm-documents.InvokeLambdaFunctionStep.formatInputMap">formatInputMap</a></code> | *No description.* |

---

Expand Down Expand Up @@ -9356,12 +9355,6 @@ Lists the outputs defined by the user for this step.
public variables(): {[ key: string ]: any}
```

##### `formatInputMap` <a name="formatInputMap" id="@cdklabs/cdk-ssm-documents.InvokeLambdaFunctionStep.formatInputMap"></a>

```typescript
public formatInputMap(): {[ key: string ]: any}
```

#### Static Functions <a name="Static Functions" id="Static Functions"></a>

| **Name** | **Description** |
Expand Down
4 changes: 2 additions & 2 deletions src/parent-steps/automation/invoke-lambda-function-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ export class InvokeLambdaFunctionStep extends AutomationStep {
return super.prepareSsmEntry(entries);
}

public formatInputMap(): Record<string, any> {
private formatInputMap(): Record<string, any> {
return {
FunctionName: this.functionName,
Qualifier: this.qualifier,
InvocationType: this.invocationType,
LogType: this.logType,
ClientContext: this.clientContext,
Payload: this.payload,
InputPayload: this.payload,
};
}
}
13 changes: 12 additions & 1 deletion src/simulation/automation/invoke-lambda-function-simulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class InvokeLambdaFunctionSimulation extends AutomationSimulationBase {
}

public executeStep(inputs: Record<string, any>): Record<string, any> {
const inputMap = this.invokeLambdaFunctionStep.formatInputMap();
const inputMap = this.formatInputMap();
const stepInputs = pruneAndTransformRecord(inputMap, x => x.resolve(inputs));
stepInputs.InvocationType = stepInputs.InvocationType ?? 'RequestResponse';
stepInputs.LogType = stepInputs.LogType ?? 'Tail';
Expand Down Expand Up @@ -55,4 +55,15 @@ export class InvokeLambdaFunctionSimulation extends AutomationSimulationBase {
};
}

private formatInputMap(): Record<string, any> {
const step = this.invokeLambdaFunctionStep;
return {
FunctionName: step.functionName,
Qualifier: step.qualifier,
InvocationType: step.invocationType,
LogType: step.logType,
ClientContext: step.clientContext,
Payload: step.payload,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('InvokeLambdaFunctionStep', () => {
InvocationType: 'type',
LogType: 'none',
ClientContext: 'context',
Payload: { a: 1 },
InputPayload: { a: 1 },
},
name: 'id2',
});
Expand Down

0 comments on commit 613f095

Please sign in to comment.