Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ async function initializeRedisClient(): Promise<RedisClientType> {

// Create Redis client with IAM credentials and TLS
// TLS is REQUIRED for IAM authentication with AWS ElastiCache
//
// Based on AWS documentation and examples (Python, Java, Go):
// Both username and password (IAM token) must be provided for AUTH
// The redis client will send: AUTH username token
client = createClient({
socket: {
host,
Expand All @@ -89,6 +93,8 @@ async function initializeRedisClient(): Promise<RedisClientType> {
return Math.min(retries * 100, 3000); // Exponential backoff, max 3s
},
},
// Provide both username and IAM-generated token for authentication
// This matches AWS documentation for IAM auth with ElastiCache
username,
password: token,
});
Expand Down
6 changes: 4 additions & 2 deletions packages/web/src/utils/elasticache-iam-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ export async function generateIAMAuthToken(
query.ResourceType = 'ServerlessCache';
}

// Create the HTTP request to sign
// Create the HTTPS request to sign
// IMPORTANT: Must use https:// protocol for signature (even though final token strips the protocol)
// This matches the Python implementation in AWS docs
const request = new HttpRequest({
method: 'GET',
protocol: 'http:',
protocol: 'https:',
hostname: endpoint,
port,
path: '/',
Expand Down