You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities/idempotency.md
+83-98Lines changed: 83 additions & 98 deletions
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,7 @@ Unless you're looking to use an [existing table or customize each attribute](#dy
87
87
88
88
Note that `fn_qualified_name` means the [qualified name for classes and functions](https://peps.python.org/pep-3155/){target="_blank" rel="nofollow"} defined in PEP-3155.
89
89
90
-
##### IaC examples
90
+
##### DynamoDB IaC examples
91
91
92
92
=== "AWS Serverless Application Model (SAM) example"
93
93
@@ -116,11 +116,24 @@ Note that `fn_qualified_name` means the [qualified name for classes and function
116
116
117
117
#### Redis cluster
118
118
119
-
**TODO**: Experiment bringing upfront Redis even at the cost of readability, as setup and usage are disconnected today causing further harm.
119
+
We recommend you start with a Redis compatible management services such as [Amazon ElastiCache for Redis](https://aws.amazon.com/elasticache/redis/){target="_blank"} or [Amazon MemoryDB for Redis](https://aws.amazon.com/memorydb/){target="_blank"}.
120
120
121
-
##### Constraints
121
+
In both services and self-hosting Redis, you'll need to configure [VPC access](https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html){target="_blank"} to your AWS Lambda.
122
122
123
-
If you'd like to use Redis, please [read here](#redis-as-persistent-storage-layer-provider) on how to setup and access secrets/SSL certs.
123
+
!!! tip "First time setting it all up? Checkout the official tutorials for [Amazon ElastiCache for Redis](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/LambdaRedis.html) or [Amazon MemoryDB for Redis](https://aws.amazon.com/blogs/database/access-amazon-memorydb-for-redis-from-aws-lambda/)"
When using DynamoDB as the persistence layer, you can customize the attribute names by passing the following parameters during the initialization of the persistence layer:
368
383
369
384
| Parameter | Required | Default | Description |
@@ -380,15 +395,68 @@ When using DynamoDB as the persistence layer, you can customize the attribute na
380
395
381
396
#### RedisPersistenceLayer
382
397
383
-
This persistence layer is built-in, allowing you to use an existing Redis service. For optimal performance and compatibility, it is strongly recommended to use a Redis service version 7 or higher.
398
+
!!! info "We recommend Redis version 7 or higher for optimal performance."
384
399
385
-
=== "Customizing RedisPersistenceLayer to suit your data structure"
400
+
For a quick start, initialize `RedisCachePersistenceLayer` and pass your cluster host endpoint along with the port to connect to.
We recommend using AWS Secrets Manager to store and rotate certificates safely, and the [Parameters feature](./parameters.md){target="_blank"} to fetch and cache optimally.
423
+
424
+
For advanced configurations, we also recommend using an existing Redis client for optimal compatibility like SSL certificates and timeout.
When using Redis as the persistence layer, you can customize the attribute names by providing the following parameters upon initialization of the persistence layer:
431
+
1. JSON stored:
432
+
```json
433
+
{
434
+
"REDIS_ENDPOINT": "127.0.0.1",
435
+
"REDIS_PORT": "6379",
436
+
"REDIS_PASSWORD": "redis-secret"
437
+
}
438
+
```
439
+
440
+
=== "Advanced configuration with local certificates"
The following sequence diagrams explain how the Idempotency feature behaves under different scenarios.
@@ -649,95 +723,6 @@ graph TD;
649
723
<i>Race condition with Redis</i>
650
724
</center>
651
725
652
-
## Redis as persistent storage layer provider
653
-
654
-
### Redis resources
655
-
656
-
Before setting up Redis as the persistent storage layer provider, you must have an existing Redis service. We recommend you to use Redis compatible services such as [Amazon ElastiCache for Redis](https://aws.amazon.com/elasticache/redis/){target="_blank"} or [Amazon MemoryDB for Redis](https://aws.amazon.com/memorydb/){target="_blank"} as your persistent storage layer provider.
657
-
658
-
???+ tip "No existing Redis service?"
659
-
If you don't have an existing Redis service, we recommend using [DynamoDB](#dynamodbpersistencelayer) as the persistent storage layer provider.
1. Replace the Security Group ID and Subnet ID to match your VPC settings.
668
-
669
-
### VPC Access
670
-
671
-
Your Lambda Function must have network access to the Redis endpoint before using it as the idempotency persistent storage layer. In most cases, you will need to [configure VPC access](https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html){target="_blank"} for your Lambda Function.
672
-
673
-
???+ tip "Amazon ElastiCache/MemoryDB for Redis as persistent storage layer provider"
674
-
If you plan to use Amazon ElastiCache for Redis as the idempotency persistent storage layer, you may find [this AWS tutorial](https://docs.aws.amazon.com/lambda/latest/dg/services-elasticache-tutorial.html){target="_blank"} helpful.
675
-
For those using Amazon MemoryDB for Redis, refer to [this AWS tutorial](https://aws.amazon.com/blogs/database/access-amazon-memorydb-for-redis-from-aws-lambda/){target="_blank"} specifically for the VPC setup guidance.
676
-
677
-
After completing the VPC setup, you can use the templates provided below to set up Lambda functions with access to VPC internal subnets.
678
-
679
-
=== "AWS Serverless Application Model (SAM) example"
1. Replace the Security Group ID and Subnet ID to match your VPC settings.
686
-
687
-
### Configuring Redis persistence layer
688
-
689
-
You can quickly get started by initializing the `RedisCachePersistenceLayer` class and applying the `idempotent` decorator to your Lambda handler. For a detailed example of using the `RedisCachePersistenceLayer`, refer to the [Persistence layers section](#redispersistencelayer).
690
-
691
-
???+ info
692
-
We enforce security best practices by using SSL connections in the `RedisCachePersistenceLayer`; to disable it, set `ssl=False`
693
-
694
-
=== "Use Persistence Layer with Redis config variables"
For advanced configurations, such as setting up SSL certificates or customizing parameters like a custom timeout, you can utilize the Redis client to tailor these specific settings to your needs.
0 commit comments