Skip to content

AWS IAM Authentication with GLIDE

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)
// TODO: add code snippet

Connecting to an ElastiCache or MemoryDB cluster configured with IAM Authentication using GLIDE, requires:

  1. Generating an IAM Authentication token using AWS SDK.
  2. Initializing the GLIDE client by passing the IAM token as part of the credentials configuration.
  3. Refreshing the token periodically with GLIDE’s Dynamic Password Update Feature.

See how to generate the token and GLIDE user examples:

Best Practices for Refreshing IAM Tokens and Re-authentication

Section titled “Best Practices for Refreshing IAM Tokens and Re-authentication”

GLIDE supports dynamic updates to the password in the connection configuration at runtime (see Dynamic Password Management for more details). This capability is required when perfoming IAM authentication with AWS SDK because:

  • IAM tokens are only valid for 15 minutes.
  • Connections authenticated with IAM must be re-authenticated every 12 hours using the AUTH or HELLO command with a fresh IAM token. Otherwise, the connection will be terminated.

To efficiently manage this, GLIDE provides the ability to update short-lived tokens using updateConnectionPassword (or update_connection_password) to periodically refresh the token without immediately re-authenticating. It also offers the option for immediate re-authentication using immediateAuth (or immediate_auth), which forces re-authentication and extends the connection for another 12 hours.