AWS - Deploying Model ( dealing with problems)
When after all procedure, the server error continues.
- "Missing Authentication Token"
- "Internal server error"
- 500 / 403 error.
Backgrounds
- I'm not used to deploying / writing html.
- There may be many errors or changes besides on a state when to try deploying.
- So I was confused how to solve these errors.
- Security level is not described here.
Errors I have gotten.
- HTML Responce shows
- {"message":"Missing Authentication Token"}
- {"message": "Internal server error"}
- Chrome DevTools Console tab (
Press F12 on chrome browser
) shows- Failed to load resource: the [Expression like Invoke URL] server responded with a status of 500 ()
- Access to XMLHttpRequest at [Expression like Invoke URL] from origin 'null' has been blocked by CORS policy: No 'Access-Control-Alllow-Origin' header is present on the requested resource.
- POST [Expression like Invoke URL] 500
- POST [Expression like Invoke URL] 403
Checkpoints
POST method written properly on html
, check if index.html has it on properly.- Though this is a basic point, but I am not used to deploy web pages, then I take time to notice this point.
The deployment process
, which we must cycling to succeed.- Create an IAM Role for the Lambda function
- This is ok to reuse, no need to reset on each trial.
- Create Lambda function
Reset the endpoint name
is mandatory on each trial. Check the name by predictor.endpoint on Notebook.
- Setting up API Gateway
- If Lambda function name is same, it may better to
recreate API itself to enable changes on Lambda function
.- I guess when recreate it, it updates the related Lambda function, and changes in Lambda function is enabled.
- If Lambda function name is same, it may better to
- Create an IAM Role for the Lambda function
-
Do not worry so much about CORS.
-
It will be working that Lambda function code includes below.
python return { 'statusCode' : 200, 'headers' : { 'Content-Type' : 'text/plain', 'Access-Control-Allow-Origin' : '*' }, 'body' : result }
*'Access-Control-Allow-Origin' : '*'
part allows all access. -
There are articles for CORS, but for me, it is not necessary to success deploying.
- CORS Wiki
- Enable CORS for an API Gateway REST API Resource
- This is same included in sample Lambda function.
- Do not mix the issue to enable GPU on Notebook.
-