Skip to content

aws_apigateway: Allow StepFunctionsIntegration to include specific headers #38529

Description

@WtfJoke

Describe the feature

Allow StepFunctionExecutionIntegrationOptions#headers to accept a list of header names in addition to a boolean (or if limited by JSII, introduce a new property headerNames).

The generated request-mapping template should forward only the specified headers.
While headers: true could retain its current behaviour of forwarding all headers.

Use Case

We need to forward a single non-sensitive header, user-id, to the Step Functions execution input. Using headers: true forwards all request headers, including sensitive values such as Authorization and Cookie, which may then appear in Step Functions execution history and logs, which I would like to avoid.

The alternative is to copy the existing template and adapt or write my own template. Dealing with vtl template is something we usually try to avoid.

Selective header forwarding would support least-privilege data handling, avoid accidental exposure of sensitive headers, and remove the need to maintain a custom Velocity mapping template.

Proposed Solution

Keep the existing headers?: boolean property for backward compatibility and add a separate JSII-compatible property for selective forwarding in https://github.com/aws/aws-cdk/blob/v2.263.0/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts#L18:

export interface StepFunctionsExecutionIntegrationOptions extends IntegrationOptions {
  /**
   * Includes all request headers in the Step Functions execution input.
   */
  readonly headers?: boolean;

  /**
   * Includes only the named request headers in the execution input.
   * Mutually exclusive with `headers: true`.
   */
  readonly headerNames?: string[];
}

Other Information

The feature request could also work with a similar pattern with querystring (and maybe path but I don't have any use cases for allowing only specific paths)

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS CDK Library version (aws-cdk-lib)

2.261.0

AWS CDK CLI version

npx cdk --version

Environment details (OS name and version, etc.)

macos 26.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-apigatewayRelated to Amazon API Gatewayeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions