Posts

Showing posts from March, 2023
Image
  Build a Secure Database Driven Web Application with Amplify and React: Part 3 - Connect to a Database Now that the backend is in place we can connect it to a database. As the Amplify backend is serverless and our business application use case requires a relational database, Aurora is the logical choice. The classical way to connect to a PostgreSQL database would be a driver like psycopg2 and leveraging a framework like Flask, Jango or FastAPI. The upside of that approach would be full control and that limitations would only be given by the used framework. But the backend would get heavier and that is not the best approach in the context of Lambda functions. Aurora Data API An alternate more lightweight solution comes with the Aurora Data API . This will provide us with a lean backend requiring only a few lines of Python code and take the load off the project created by connection pooling considerations etc. There are just a few serious restrictions we need to be aware of: Availa...

Build a Secure Database Driven Web Application with Amplify and React: Part 2 - Add the Backend

Image
In Part 1, we have built and deployed a secure serverless application to the web. It's functionality ist just quite limited without a backend. So let's change this. Start adding the backend with      > amplify add api The command is interactive and asks for the following options: API Type REST Give it a descriptive name (in our case ardemo like the application will do) The path is the path to the resource and should get its name, for example    /customers/{id} ID in curly brackets serves as a path parameter Programming language: Python We do not need advanced options at this moment Restrict the API to authenticated users and open it to all operations Amplify will create a folder and file structure under the projec/amplify folder. The created lambda function resides in the file /src/index.py: import json def handler ( event , context ): print ( 'received event:' ) print ( event ) return { 'statusCode' : 200 , 'headers' : { ...

Build a Secure Database Driven Web Application with Amplify and React: Part 1 - Setup

Image
In my recent post I have published a demo CRUD application utilizing React.js, AWS Amplify and PostgreSQL on Aurora. For everyone who did not want to sign up and take a look for any reason, here's a screenshot: In the next posts, I want to document how easy it is to build a secure serverless web application on top of Amplify using React as a frontend. AWS account AWS command line tools including amplify are installed and connected to the account Installed Node.js (version >=17) and React.js (version >=18.2) An IDE of choice like VS code Initialize the Project To set up the project, have a code editor ready and an terminal window with command prompt. First, we initialize the React application and give it a name like ardemo for Amplify-React Demo.      > npx create-react-app ardemo A directory with the project name will be created, we change to that and can run the intial React application right away:   > cd ardemo > npm start  By default, the node ...