Set header value for proxied request programatically

I’ve found an approach to being able to use the serverless framework and be able to hard code integration request header values and utilise HTTP_PROXY instead of maintaining a LAMBDA_PROXY.

I had to write an intermediary python script to programmatically edit the Cloudformation that the serverless tool creates.

Deployment steps as follows:

  1. Use the yml fucntion configuration defined in the original post.
  2. Create a package, sls package --package <YOUR_PACKAGE_NAME> --stage <STAGE>
  3. Run the python script to change the integration.request.header.Authorization value in the <YOUR_PACKAGE_NAME>/cloudformation-template-update-stack.json and <YOUR_PACKAGE_NAME>/serverless-state.json files
  4. Deploy the package sls deploy --package <YOUR_PACKAGE_NAME> --stage <STAGE>

I bundled these commands together in a Makefile so I could call a single command for packaging, updating and deploying:

make deploy-<STAGE>