From 613f095d7ae3c3ad77950830169b666727fc13b6 Mon Sep 17 00:00:00 2001
From: jcgould2021 <104597354+jcgould2021@users.noreply.github.com>
Date: Wed, 1 Mar 2023 16:30:30 -0500
Subject: [PATCH] fix: use InputPayload for ssm entry of
aws:invokeLambdaFunction (#58)
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.
---
API.md | 7 -------
.../automation/invoke-lambda-function-step.ts | 4 ++--
.../automation/invoke-lambda-function-simulation.ts | 13 ++++++++++++-
.../automation/invoke-lambda-function-step.test.ts | 2 +-
4 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/API.md b/API.md
index daf8083..aa6b0eb 100644
--- a/API.md
+++ b/API.md
@@ -9294,7 +9294,6 @@ new InvokeLambdaFunctionStep(scope: Construct, id: string, props: InvokeLambdaFu
| addToDocument
| *No description.* |
| listUserOutputs
| Lists the outputs defined by the user for this step. |
| variables
| *No description.* |
-| formatInputMap
| *No description.* |
---
@@ -9356,12 +9355,6 @@ Lists the outputs defined by the user for this step.
public variables(): {[ key: string ]: any}
```
-##### `formatInputMap`
-
-```typescript
-public formatInputMap(): {[ key: string ]: any}
-```
-
#### Static Functions
| **Name** | **Description** |
diff --git a/src/parent-steps/automation/invoke-lambda-function-step.ts b/src/parent-steps/automation/invoke-lambda-function-step.ts
index feba190..4871674 100644
--- a/src/parent-steps/automation/invoke-lambda-function-step.ts
+++ b/src/parent-steps/automation/invoke-lambda-function-step.ts
@@ -106,14 +106,14 @@ export class InvokeLambdaFunctionStep extends AutomationStep {
return super.prepareSsmEntry(entries);
}
- public formatInputMap(): Record {
+ private formatInputMap(): Record {
return {
FunctionName: this.functionName,
Qualifier: this.qualifier,
InvocationType: this.invocationType,
LogType: this.logType,
ClientContext: this.clientContext,
- Payload: this.payload,
+ InputPayload: this.payload,
};
}
}
\ No newline at end of file
diff --git a/src/simulation/automation/invoke-lambda-function-simulation.ts b/src/simulation/automation/invoke-lambda-function-simulation.ts
index 06efc6b..aa75969 100644
--- a/src/simulation/automation/invoke-lambda-function-simulation.ts
+++ b/src/simulation/automation/invoke-lambda-function-simulation.ts
@@ -26,7 +26,7 @@ export class InvokeLambdaFunctionSimulation extends AutomationSimulationBase {
}
public executeStep(inputs: Record): Record {
- 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';
@@ -55,4 +55,15 @@ export class InvokeLambdaFunctionSimulation extends AutomationSimulationBase {
};
}
+ private formatInputMap(): Record {
+ const step = this.invokeLambdaFunctionStep;
+ return {
+ FunctionName: step.functionName,
+ Qualifier: step.qualifier,
+ InvocationType: step.invocationType,
+ LogType: step.logType,
+ ClientContext: step.clientContext,
+ Payload: step.payload,
+ };
+ }
}
\ No newline at end of file
diff --git a/test/parent-steps/automation/invoke-lambda-function-step.test.ts b/test/parent-steps/automation/invoke-lambda-function-step.test.ts
index 6a696d3..9a32b6a 100644
--- a/test/parent-steps/automation/invoke-lambda-function-step.test.ts
+++ b/test/parent-steps/automation/invoke-lambda-function-step.test.ts
@@ -112,7 +112,7 @@ describe('InvokeLambdaFunctionStep', () => {
InvocationType: 'type',
LogType: 'none',
ClientContext: 'context',
- Payload: { a: 1 },
+ InputPayload: { a: 1 },
},
name: 'id2',
});