Skip to content

SFN Client throws InvalidSignatureException due to AWS SigV4 signature expiration in Lambda #7135

Open
@bayoudhi

Description

@bayoudhi

Checkboxes for prior research

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.

Image

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.)

Image

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

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p3This is a minor priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions