-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could you elaborate on the AWS API Gateway? #2
Comments
Hi. Ive just got this working - took some time and some playing about but this was roughly my workflow:
Make sure you attach an API Gateway trigger. Then head over to the API Gateway section for the rest of the configuration. I created a POST method. I edited the POST method and set "Auth" to none and "API key required" to true. I had to untick "Use Lambda Proxy integration" in Method Execution. Config screenshot 1 I enabled CORS here also with permissive defaults. Make sure you Deploy the API to /prod (or whatver your stage was named) after any edits before you try hitting the URL. Finally in the S3 bucket configuration i used this CORS Policy:
I was then able to use POSTman/Insomnia to hit the /prod/getSignedUrl endpoint with a POST request, with an x-api-key header set to the API key generated for the usage plan. Heres a curl example of how i hit the API to get a signed URL that worked fine to PUT a file direct to S3:
Apologies for the somewhat chaotic / incomplete instructions. I spent some time getting it to work and this is a memory dump of what was actually important :) If you hit any issues i can attempt to answer based on my now working setup. |
Thank you these will be super helpful will hopefully get to integrating over the weekend |
Worth noting that if you require an API Key in API Gateway config will need a tweak to the frontend JS code to include it as an x-api-key header. If your happy with open access to the lamda function for public upload you can set API Key Required False. My app this is not acceptable and i want all PUTs to only come from authorized clients. |
Hi @fibble. Can you share your S3 bucket policy config? How can we allow PUT only for pre-signed action (don't know how to call it right). Something like this:
But I can't get what should I specify on |
I think it will be a good idea to merge this issue to the documentation. |
For the ones facing CORS issues with this, follow @fibble instructions and then modify the "API Responses" to add "allow-access-control-origin" in the responses (of the options and the post method). |
For me |
Hey I am a little new to the AWS stuff and I would like to know the purpose of the API Gateway?
I am currently working on an electron application and trying to figure out how I can securely use AWS Lambda (i.e where do I store my AWS credentials etc...) I am thinking I may need to set up a proxy service that will hold the AWS credentials on the server side?
But I am wondering if the API Gateway is intended to cover this?
Cheers.
The text was updated successfully, but these errors were encountered: