AWS AmazonElastiCache: Migrate Lambda+ElastiCache tutorial from Redis OSS to Valkey
Summary
Rewrites the Lambda/ElastiCache serverless tutorial to use Valkey instead of Redis OSS: engine flags changed to valkey, Python client switched from redis-py to valkey-py, links updated to the Valkey serverless cache page, and the step that created a disabled 'default' user was removed so only the IAM-enabled user is added to the user group.
Security assessment
The change is primarily a Redis OSS -> Valkey rebranding (engine valkey, valkey-py client, updated links). The one security-relevant edit is the deletion of the guidance to create a default user with access disabled, which previously ensured only explicitly configured IAM users could connect; removing that hardening step slightly weakens the documented least-privilege posture, but no vulnerability, CVE, or incident is referenced and the IAM auth flow itself is unchanged.
Evidence
- 1. Create a default user with access disabled. Every user group requires a default user. By disabling access on this user, you ensure that only explicitly configured IAM users can connect.
Diff
diff --git a/AmazonElastiCache/latest/dg/LambdaRedis.md b/AmazonElastiCache/latest/dg/LambdaRedis.md index d26bcd7..39b77ee 100644 --- a//AmazonElastiCache/latest/dg/LambdaRedis.md +++ b//AmazonElastiCache/latest/dg/LambdaRedis.md @@ -32 +32 @@ To create a serverless cache, follow these steps. -In this step, you create a serverless cache in the default Amazon VPC in the us-east-1 region in your account using the AWS Command Line Interface (CLI). For information on creating serverless cache using the ElastiCache console or API, see [Create a Redis OSS serverless cache](./GettingStarted.serverless-redis.step1.html). +In this step, you create a serverless cache in the default Amazon VPC in the us-east-1 region in your account using the AWS Command Line Interface (CLI). For information on creating serverless cache using the ElastiCache console or API, see [Create a Valkey serverless cache](./GettingStarted.serverless-valkey.step1.html). @@ -44 +44 @@ Note that the value of the Status field is set to `CREATING`. ElastiCache create -Verify that ElastiCache for Redis OSS has finished creating the cache with the `describe-serverless-caches` command. +Verify that ElastiCache has finished creating the cache with the `describe-serverless-caches` command. @@ -110,10 +110 @@ This step is required. Your Lambda function authenticates to ElastiCache using I - 1. Create a default user with access disabled. Every user group requires a default user. By disabling access on this user, you ensure that only explicitly configured IAM users can connect. - - aws elasticache create-user \ - --user-name default \ - --user-id default-user-disabled \ - --engine redis \ - --authentication-mode Type=no-password-required \ - --access-string "off +get ~keys*" - - 2. Create an IAM-enabled user. This is the user identity that your Lambda function will authenticate as. + 1. Create an IAM-enabled user. This is the user identity that your Lambda function will authenticate as. @@ -125 +116 @@ This step is required. Your Lambda function authenticates to ElastiCache using I - --engine redis \ + --engine valkey \ @@ -128 +119 @@ This step is required. Your Lambda function authenticates to ElastiCache using I - 3. Create a user group, add both users to it, and associate the group with your cache. + 2. Create a user group, add the user to it, and associate the group with your cache. @@ -132,2 +123,2 @@ This step is required. Your Lambda function authenticates to ElastiCache using I - --engine redis \ - --user-ids default-user-disabled iam-user-01 + --engine valkey \ + --user-ids iam-user-01 @@ -159 +150 @@ The following example Python code reads and writes an item to your ElastiCache c - import redis + import valkey @@ -165 +156 @@ The following example Python code reads and writes an item to your ElastiCache c - class ElastiCacheIAMProvider(redis.CredentialProvider): + class ElastiCacheIAMProvider(valkey.CredentialProvider): @@ -214 +205 @@ The following example Python code reads and writes an item to your ElastiCache c - redis_client = redis.Redis(host=elasticache_endpoint, port=6379, credential_provider=creds_provider, ssl=True, ssl_cert_reqs="none") + valkey_client = valkey.Valkey(host=elasticache_endpoint, port=6379, credential_provider=creds_provider, ssl=True, ssl_cert_reqs="none") @@ -219,2 +210,2 @@ The following example Python code reads and writes an item to your ElastiCache c - redis_client.set(key, uuid_in) - result = redis_client.get(key) + valkey_client.set(key, uuid_in) + result = valkey_client.get(key) @@ -231 +222 @@ The following example Python code reads and writes an item to your ElastiCache c -This code uses the Python redis-py library to put items into your cache and retrieve them. This code uses cachetools to cache generated IAM Auth tokens for 15 mins. To create a deployment package containing redis-py and cachetools, carry out the following steps. +This code uses the Python valkey-py library to put items into your cache and retrieve them. This code uses cachetools to cache generated IAM Auth tokens for 15 mins. To create a deployment package containing valkey-py and cachetools, carry out the following steps. @@ -233 +224 @@ This code uses the Python redis-py library to put items into your cache and retr -In your project directory containing the app.py source code file, create a folder package to install the redis-py and cachetools libraries into. +In your project directory containing the app.py source code file, create a folder package to install the valkey-py and cachetools libraries into. @@ -238 +229 @@ In your project directory containing the app.py source code file, create a folde -Install redis-py, cachetools using pip. +Install valkey-py, cachetools using pip. @@ -241 +232 @@ Install redis-py, cachetools using pip. - pip install --target ./package redis + pip install --target ./package valkey @@ -244 +235 @@ Install redis-py, cachetools using pip. -Create a .zip file containing the redis-py and cachetools libraries. In Linux and macOS, run the following command. In Windows, use your preferred zip utility to create a .zip file with the redis-py and cachetools libraries at the root. +Create a .zip file containing the valkey-py and cachetools libraries. In Linux and macOS, run the following command. In Windows, use your preferred zip utility to create a .zip file with the valkey-py and cachetools libraries at the root.