Using IAM authentication for Amazon MemoryDB and ElastiCache
How to securely connect your Go applications using IAM authentication
As a bonus, this is also applicable to ElastiCache for Redis, which also supports IAM authentication. There are minor differences which I will list at the end of the blog.


- Make sure to use same VPC and subnet as the MemoryDB cluster
- Update the MemoryDB subnet group to add inbound rule for the client application connectivity.
run.sh
file to enter the MemoryDB cluster endpoint, and username. For example:You can refer to the authentication code in the GitHub repository
HTTP
GET
request that contains the cluster name as part of the URL along with username, the action (connect
) and token expiry (900 seconds) as query parameters:CredentialsProvider
during client creation:SERVICE_NAME
environment variable to elasticache
as well as the endpoint URL, cluster name and IAM username for the ElastiCache instance.redis.NewClient
(instead of redis.NewClusterClient
). The CredentialsProvider
option will be available nonetheless.MULTI EXEC
commands. For a complete list, refer to the documentation.Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.