4: API Gateway
·1 min
Table of Contents
What is API Gateway?
- Make your own REST or websocket APIs
- Connect programmers (via HTTP GET and POST requests) to:
- Lambdas
- DynamoDB
- Ec2
- S3
- Caches
- Cloudwatch
- Etc.
REST vs Websockets?
- REST: 1-way comms; simple request/response
- Socket: 2-way comms; e.g. update the GUI as we go
- Backend service can initiate comms
- Real-time chat is one good example
Authentication?
- Web identity federation stuff
What about HTTP APIs?
- Cheaper and faster than REST
- Still lacking full functionality of REST
- Go with HTTP unless you need those extra functionalities
What’s Lambda Proxy Integration?
- You can proxy requests as-is to lambda funcs
- You can point API Gateway to lambda aliases
- E.g. point to “prod” rather than “version 2”
- You have to give API gateway permission to invoke a lambda function
- The function has a resource-based policy to allow this
How is the API updated automatically?
- When you add an API to your function—
- …via lambda console,
- …via API gateway console,
- …or via SAM template,
- The resource-based policy is updated automatically.