cpp/example_code/cross-service/serverless-aurora/README.md
This example code creates an HTTP server which implements the following APIs.
GET /items to query all items.GET /items?archived=true to query archived items, archived=false to query active items.GET /items/{item_id} to query a single item.POST /items to create a new item in the collection.PUT /items/{item_id} to update an individual item.PUT /items/{item_id}:archive to move an individual item to the archived status.POST /items:report to generate a report. The body can accept an email field with a string email address.The data for these APIs is stored in an Amazon Aurora Serverless database. The email report is sent using Amazon Simple Email Service (Amazon SES).
This example uses C++ code, JavaScript React code, and AWS Cloud Development Kit (AWS CDK) code.
The example code in this folder creates an HTTP server which accesses AWS services using the AWS SDK for C++.
A client JavaScript React web app is created using the code at resources/clients/react/elwing.
The Amazon Aurora Serverless resources are created using the AWS CDK code at resources/cdk/aurora_serverless_app.
The Amazon RDS resources for this example can be created by running the AWS CloudFormation
setup.yaml script in
resources/cdk/aurora_serverless_app.
For instructions on how to run the script, see the README.
A verified identity must be created in Amazon SES.
mkdir build
cd build
On Linux and Mac.
conan install .. --build=missing
On Windows.
conan install .. --build=missing -o poco:shared=True -s build_type=Debug
cmake ..
make ..
Run the HTTP server from the command line with the necessary arguments.
./run_serverless_aurora <database> <resource_arn> <secret_arn> <email>
The "database", "resource_arn", and "secret_arn" were obtained in the preceding "Create the resources" step.
The "email" is a verified identity created in Amazon SES.
Now run the client app to communicate with the "run_serverless_aurora" HTTP server. The ReadMe contains instructions for running the client web app.
When both the client app and the HTTP server app are running, AWS resources can be manipulated from a webpage. The client app will appear in your web browser. Select "Item Tracker" in the webpage sidebar to open the webpage which communicates with the HTTP server.
To avoid charges, delete all the resources that you created for this tutorial. Follow the instructions in the "Destroying resources" section of the README for the Aurora Serverless CDK deployment.
Congratulations! You have built a web application that reads, writes, and archives work items that are stored in an Amazon Aurora Serverless database. The web application also uses Amazon SES to send email from a verified user.