Skip to content

Configure AWS IAM Authentication

GLIDE 2.2+ provides built-in support for AWS Identity and Access Management (IAM) authentication when connecting to Amazon ElastiCache and MemoryDB clusters. This feature automatically handles token generation and rotation, making it simple to maintain secure connections.

  • GLIDE automatically generates temporary authentication tokens that are valid for 15 minutes
  • GLIDE refreshes the token every 5 minutes. On failure, it retries with exponential backoff and keeps using the last valid token until refreshed
  • Each connection remains valid for up to 12 hours before requiring re-authentication
  • GLIDE handles all token management and refresh operations behind the scenes
  • Manual option available via refreshIamToken
  1. AWS Credentials: Your application must run in an environment with AWS credentials available (such as an EC2 instance with an IAM role, or ECS task with a task role).

  2. Required Information:

  • username: Your ElastiCache/MemoryDB username
  • cluster_name: Your cluster’s name
  • service: Either ElastiCache or MemoryDB
  • region: The AWS region where your cluster runs
  • refreshIntervalSeconds (Optional): How often to refresh the token. Default is 300 seconds (5 minutes)
from glide import (
GlideClusterClient,
GlideClusterClientConfiguration,
IamAuthConfig,
NodeAddress,
ServerCredentials,
ServiceType,
)
...
addresses = [NodeAddress("endpoint.example.com", 6379)]
# Configure IAM authentication
# Automatically regenerates the token every 5 mins (default: 300 seconds)
iam_config = IamAuthConfig(
cluster_name="clustername",
service=ServiceType.ELASTICACHE, # or ServiceType.MEMORYDB
region="us-east-1",
# refresh_interval_seconds=100, # Optional, default is 300 seconds
)
credentials = ServerCredentials(username="username", iam_config=iam_config)
config = GlideClusterClientConfiguration(
addresses=addresses,
credentials=credentials,
)
# for async mode
client = await GlideClusterClient.create(config)
# for sync mode
client = GlideClusterClient.create_sync(config)
...