Open
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
We're encountering an InvalidSignatureException
due to AWS SigV4 signature expiration when using the SFN client in a Lambda function that's triggered by an SQS FIFO queue. The error indicates that the request signature has expired beyond the 5-minute window allowed by AWS.
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/[email protected], ...
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
Node.js 20.x (Lambda NodeJS runtime)
Reproduction Steps
Original Code (without credential resolution)
const { STATE_MACHINE_ARN } = process.env as StartAnalyticsStateMachineWorkerEnv;
const sfn = new SFNClient({});
const recordHandler = async (record: SQSRecord) => {
try {
await sfn.send(
new StartSyncExecutionCommand({
stateMachineArn: STATE_MACHINE_ARN,
input: record.body,
})
);
} catch (error) {
logger.error("Error processing record", {
error,
record,
});
throw error;
}
};
const processor = new SqsFifoPartialProcessor();
export const handler: SQSHandler = async (event, context) =>
processPartialResponseSync(event, recordHandler, processor, {
context,
});
Attempted Fix (with forced credential resolution)
const recordHandler = async (record: SQSRecord) => {
try {
await sfn.config.credentials(); // force credential resolution - DIDN'T WORK
await sfn.send(
new StartSyncExecutionCommand({
stateMachineArn: STATE_MACHINE_ARN,
input: record.body,
})
);
} catch (error) {
logger.error("Error processing record", {
error,
record,
});
throw error;
}
};
Observed Behavior
Signature expired: 20250617T103212Z is now earlier than 20250617T103417Z (20250617T103917Z - 5 min.)
Expected Behavior
The SFN client should generate fresh AWS SigV4 signatures for each request and execute the Step Function without signature expiration errors.
Possible Solution
No response
Additional Information/Context
- AWS SDK Version: @aws-sdk/client-sfn": "3.226.0"
- Runtime: AWS Lambda (Node.js)
- Trigger: SQS FIFO Queue
- Additional Dependencies: Using SQS partial batch processing from [AWS Lambda Powertools](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/batch/#fifo-queues)