This project was built on top of the AWS Serverless Application Model. First, I will describe how to build the model and then add the necessary dependencies to personlize the logs
[x] Logging implementation [x] X-ray Tracing [x] CloudWatch Centralization [x] Documentation
If we want to modify to insert more tracing and logging we Can do it adding the following dependencies to the Toml file:
Then we need to use them in the main.rs
And finally we add those into the async function:
Nonetheless the SAM framework builds by default a tracing mechanism:
And logs by default, the following is a screenshot after adding an item to the Dynamo table:
To know more about SAM, read the following instructions.
This repository contains the source code and configuration files for a serverless application built on AWS using the Serverless Application Model (SAM). The application consists of a Lambda function written in Rust, which interacts with a DynamoDB database to update data based on incoming payloads.
Before deploying and running this serverless application, ensure that you have the following prerequisites set up:
-
AWS account
-
AWS CLI installed and configured
-
SAM CLI installed
-
Rust programming language installed (for building the Lambda function locally)
To deploy and run the serverless application (SAM), follow these steps:
- Create a virtual environment:
python -m venv venv
source venv/bin/activate
Sometimes you need to deactivate conda
conda deactivate
- install the necessary dependencies:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
aws configure
Here you need to add the necessary IAM permissions:
pip install aws-sam-cli
Install cargo if you don't have it:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Deploy the Application:
sam deploy --guided
Follow the prompts to configure your deployment. SAM will package and deploy your application stack to AWS.
-
Test the Application: Once the deployment is complete, you can test the application by invoking the Lambda function or sending payloads to trigger updates in the DynamoDB table.
- Lambda Function: The Rust code for the Lambda function resides in the
lambda_function
directory. Update the code logic insrc/main.rs
according to your requirements.
- DynamoDB Table: The application interacts with a DynamoDB table to update data. Ensure that you have the necessary permissions and configuration set up in AWS.
lambda_function
: Contains the source code for the Rust Lambda function.template.yaml
: SAM template file defining the AWS resources for the serverless application.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the AWS team for providing the Serverless Application Model (SAM) framework.
- Inspiration and guidance from various serverless application examples and tutorials.
Feel free to reach out to me if you have any questions or need further assistance!