Skip to content

Allow Specifying Parameter (Header, Querystring, Path) Mapping Values for API Gateway Integrations #6911

Description

@scarpenter

Feature Proposal

Allow specifying mapping values when providing parameters to an API Gateway integration. This would allow configurations like this (that can be created via the AWS console) to be created in serverless:
execution_headers

Description

Currently, request parameters can be specified in AWS API Gateway integrations as part of request/parameters. The value provided for each parameter indicates whether it is required or not.

events:
  - http:
      path: /test/path
      method: get
      integration: http
      request:
        uri: https://some-backend.uri/path
        parameters:
          querystrings:
            value1: true
            value2: false
          headers:
            X-Custom-Header: false

This is then used in two places in the resulting CloudFormation template:

  1. In the RequestParameters element of the AWS::ApiGateway::Method where the "requiredness" of each parameter is declared.
  2. In the RequestParameters element of the method's Integration element where currently the parameter value is always the full "path" of the parameter (method.request.header.X-Venga-Api-Host for example).

The first usage doesn't need to be changed; it's the second that allows mapping of a different value.

A solution would be to enhance the configuration to allow specifying a mapping value in addition to whether or not the parameter is required:

events:
  - http:
      path: /test/path
      method: get
      integration: http
      request:
        uri: https://some-backend.uri/path
        parameters:
          querystrings:
            value1: true
            value2: false
          headers:
            X-Custom-Header:
              required: false
              mappedValue: context.domainName

This would then update the output for the second section of the CloudFormation template. The ability to only specify whether the parameter is required would also be retained for backward compatibility and simplicity where mapping is not desired.

I have a prototype of this change working if this is something that would be accepted into the project.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions