Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Commit 152e607

Browse files
authored
Fix redis connection for https (#75)
1 parent eb4542c commit 152e607

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/web/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ async function initializeRedisClient(): Promise<RedisClientType> {
7171

7272
// Create Redis client with IAM credentials and TLS
7373
// TLS is REQUIRED for IAM authentication with AWS ElastiCache
74+
//
75+
// Based on AWS documentation and examples (Python, Java, Go):
76+
// Both username and password (IAM token) must be provided for AUTH
77+
// The redis client will send: AUTH username token
7478
client = createClient({
7579
socket: {
7680
host,
@@ -89,6 +93,8 @@ async function initializeRedisClient(): Promise<RedisClientType> {
8993
return Math.min(retries * 100, 3000); // Exponential backoff, max 3s
9094
},
9195
},
96+
// Provide both username and IAM-generated token for authentication
97+
// This matches AWS documentation for IAM auth with ElastiCache
9298
username,
9399
password: token,
94100
});

packages/web/src/utils/elasticache-iam-auth.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ export async function generateIAMAuthToken(
5454
query.ResourceType = 'ServerlessCache';
5555
}
5656

57-
// Create the HTTP request to sign
57+
// Create the HTTPS request to sign
58+
// IMPORTANT: Must use https:// protocol for signature (even though final token strips the protocol)
59+
// This matches the Python implementation in AWS docs
5860
const request = new HttpRequest({
5961
method: 'GET',
60-
protocol: 'http:',
62+
protocol: 'https:',
6163
hostname: endpoint,
6264
port,
6365
path: '/',

0 commit comments

Comments
 (0)