Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 6 days 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 (11 months ago)
- Default Branch: master
- Last Pushed: 2024-05-02T23:10:11.000Z (7 months ago)
- Last Synced: 2024-05-03T07:16:25.358Z (7 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
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-full-event.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-full-event-data.png)#### SQS Message Body idempotent
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-body.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-body-data.jpeg)#### SQS Message Body field idempotent
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-body-field.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-body-field-data.png)#### SQS Message Body multiple fields idempotent
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-body-multiple-fields.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-body-multiple-fields-data.png)#### SQS Message ID idempotent
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-id.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-id-data.png)#### SQS Message Attribute idempotent
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-attribute.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/sqs/sqs-message-attribute-data.png)### API Gateway
#### API Gateway Full Path idempotent
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/api-gateway/api-gw-full-path-1.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/api-gateway/api-gw-full-path-2.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/api-gateway/api-gw-full-path-data-1.png)
![Image](https://github.com/gabrielleandro0801/typescript-aws-lambda-native-idempotency/blob/master/images/fn-wrapper/api-gateway/api-gw-full-path-data-2.png)