https://github.com/having-fun-serverless/web-adapter-example
A working example using Amplification and the AWS Web Adapter extension
https://github.com/having-fun-serverless/web-adapter-example
Last synced: 9 months ago
JSON representation
A working example using Amplification and the AWS Web Adapter extension
- Host: GitHub
- URL: https://github.com/having-fun-serverless/web-adapter-example
- Owner: having-fun-serverless
- License: apache-2.0
- Created: 2022-12-30T13:43:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-05T07:14:23.000Z (over 3 years ago)
- Last Synced: 2024-04-05T18:39:54.072Z (over 2 years ago)
- Language: TypeScript
- Size: 365 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://opensource.org/licenses/Apache-2.0)
Amplification + AWS Lambda Adapter
AWS Lambda Adapter is the best kept secret that you can use in order to migrate non-lambda native application to the Lambda world.
The following repo shows an example of using a Nest based application created with Amplication which is connected to a RDS database and exposed
to the outside world using Lambda URL and a Lambda Web Adapter.
Report Bug
·
Request Feature
Table of Contents
## High level architecture
1. A NestJS application created with the Amplication development tool.
2. The application runs inside a Lambda using a docker image created by Amplication.
3. The Lambda is connected to the outside world using Lambda URL functionality.
4. And it's located inside a private subnet with an access to an RDS database.
## Getting started
### Prerequisites
* Make sure your machine is ready to work with [AWS SAM](https://aws.amazon.com/serverless/sam/)
### Installation
* Clone this repository.
* Run `sam build` and then `sam deploy --guided`.
* Choose user name and password for the DB.
* Make sure you a key pair for the bastion station.
* The Lambda URL has no authentication on purpose, the authentication is being handled by NestJS.
### Testing
* Access the Lambda URL end point and append `/api`, for example `https://****.lambda-url.us-east-1.on.aws/api`.
* Authorize using `admin` as user and password, and make a call.

## Landmarks
* Defining the extension to be part of your docker file - https://github.com/aws-hebrew-book/web-adapter-example/blob/f787c8c8689259132db70b48b817da16217a5b7b/server/Dockerfile#L28
* NestJS application runs on port 8080 - https://github.com/aws-hebrew-book/web-adapter-example/blob/f787c8c8689259132db70b48b817da16217a5b7b/server/template.yaml#L206
* Authentication handled by NestJS - https://github.com/aws-hebrew-book/web-adapter-example/blob/f787c8c8689259132db70b48b817da16217a5b7b/server/template.yaml#L210
* Initial DB migration - https://github.com/aws-hebrew-book/web-adapter-example/blob/f787c8c8689259132db70b48b817da16217a5b7b/server/template.yaml#L125
* Using secret manager to save credentials - https://github.com/aws-hebrew-book/web-adapter-example/blob/f787c8c8689259132db70b48b817da16217a5b7b/server/template.yaml#L164
* **Anti Pattern** Embedding the credentials as part of UserData, this solution is quick and dirty, use SecretsManager - https://github.com/aws-hebrew-book/web-adapter-example/blob/f787c8c8689259132db70b48b817da16217a5b7b/server/template.yaml#L124
### Monitoring
Monitoring is done by using [Lumigo](https://platform.lumigo.io/auth/signup)
## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License
Distributed under the Apache License Version 2.0 License. See `LICENSE` for more information.
## Contact
Efi Merdler-Kravitz - [@TServerless](https://twitter.com/TServerless)