https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency
Repository with an example of AWS Lambda using its native idempotency validation in Typescript using Localstack
https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency
aws-lambda aws-powertools idempotency nodejs typescript
Last synced: 5 months ago
JSON representation
Repository with an example of AWS Lambda using its native idempotency validation in Typescript using Localstack
- Host: GitHub
- URL: https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency
- Owner: gabrielleandro0801
- License: mit
- Created: 2023-12-19T23:28:39.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-02T23:10:11.000Z (about 1 year ago)
- Last Synced: 2024-12-29T22:32:05.415Z (6 months ago)
- Topics: aws-lambda, aws-powertools, idempotency, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 1.11 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Typescript AWS Lambda Native Idempotency
Repository with examples of AWS Lambdas using its native idempotency validation in Typescript## Setup
1. In order to run Localstack, you will need to have *Docker* installed in your machine.
You can follow this [link](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04-pt) to install.
2. Then, you will need to install Localstack itself.
This [link](https://github.com/localstack/localstack) may help you.
3. After this, you should install *awscli-local* by following this [link](https://pypi.org/project/awscli-local/) or just running this command:``` shell
pip3 install awscli-local
```## Running :computer:
1. Start Localstack
``` shell
LAMBDA_REMOTE_DOCKER=0 DEBUG=1 localstack start
```2. Create the DynamoDB idempotency table
``` shell
awslocal dynamodb create-table \
--table-name idempotency \
--attribute-definitions \
AttributeName=identifier,AttributeType=S \
AttributeName=idempotency_hash,AttributeType=S \
--key-schema \
AttributeName=identifier,KeyType=HASH \
AttributeName=idempotency_hash,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST \
--region us-east-1
```3. Run the **package.json** scripts
4. After running each of them, scan the DynamoDB table to check the idempotency records.
``` shell
awslocal dynamodb scan \
--table-name idempotency
```In case you want to delete the table to create it again, run the following command:
``` shell
awslocal dynamodb delete-table \
--table-name idempotency
```## Function Wrapper
### SQS
#### SQS Full Event idempotent

#### SQS Message Body idempotent

#### SQS Message Body field idempotent

#### SQS Message Body multiple fields idempotent

#### SQS Message ID idempotent

#### SQS Message Attribute idempotent

### API Gateway
#### API Gateway Full Path idempotent



