5

Screenshot of URL Path Parameters Mapping in method test section of API Gateway

I'm attempting to deploy a greedy path parameter for a proxy endpoint in API Gateway. However every time I deploy the next time I try to use the proxying path, it fails to transform the proxy value in the path parameter. The only way I've found to set the mapping for the proxy parameter is in the Console via the method testing in the "Integration Request" tab UI pictured above. However I'm using the CDK to deploy this and cannot find the equivalent setting in the CDK documentation. I've tried below but with no success

api.root.addProxy({
    defaultIntegration: new apigw.HttpIntegration(`OLD_ENDPOINT/{proxy}`),
    defaultMethodOptions: {
      requestParameters: {
        'method.request.path.proxy': true,
      },
    },
  });

1 Answer 1

6

You have to combine the MethodOptions and IntegrationOptions like that:

api.root.addProxy({
  defaultIntegration: new HttpIntegration('NEW_API_URL/{proxy}', {
    httpMethod: 'ANY',
    options: {
      requestParameters: {
        'integration.request.path.proxy': 'method.request.path.proxy',
      },
    },
  }),
  defaultMethodOptions: {
    requestParameters: {
      'method.request.path.proxy': true,
    },
  },
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.