Here is the scenario:
- I had a Chalice app with two endpoints
/getStream
and/deleteStream
. - I migrated them to Nextjs functions eliminating the need for a Chalice app.
- So, I deleted the API Gateway but retained the Lambda function for backup.
import re
from urllib import request
from chalice import Chalice, Response
from chalicelib.streamEngine import StreamEngine
app = Chalice(app_name='mux-streaming')
print(app, "chalice app")
# for testing purpose
@app.route('/', methods=['GET'], cors=True, authorizer=None)
def hello():
print("hello")
return "hello"
@app.route('/getStream', methods=['POST'], cors=True, authorizer=None)
def get_stream():
request = app.current_request.json_body
creatorID = request['creatorID']
streamName = request['streamName']
streamType = request['streamType']
streamer = StreamEngine()
return streamer.getStream(creatorID, streamName, streamType)
@app.route('/deleteStream', methods=['POST'], cors=True)
def delete_stream():
request = app.current_request.json_body
streamID = request['streamID']
stream = StreamEngine()
return stream.deleteStream(streamID)
- Due to some reason, I want to migrate back to Chalice app but I don’t have infra-as-code as it was done by another dev.
- So, I added an API Gateway from AWS Console.
- But the API Gateway throws authorization errors:
On GET https://invoke-url/prod
:
{
"message": "Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. Authorization=asdf"
}
which makes no sense as I don’t have any authorization whatsoever.
On POST https://invoke-url/prod/getStream
:
{
"headers": {},
"multiValueHeaders": {},
"statusCode": 500,
"body": "{"Code":"InternalServerError","Message":"Unknown request."}"
}
To make sure API Gateway isn’t the imposter, I tried it with other lambdas and it just works fine.
Any help will be appreciated. Thanks