Prerequisites
- An ElastiCache cluster running Redis OSS 6.0 or later, with encryption in transit turned on and set to Required
- A cluster that doesn’t already use a user group of your own (see Cluster access controls)
- A role in the Infisical project that lets you create dynamic secrets
Cluster access controls
ElastiCache uses user groups to decide who can log in to a cluster. Infisical creates a user group for each cluster, namedinfisical- followed by a hash of the cluster name, and attaches the group to the cluster:
- Each lease adds a user to its own cluster’s group, so the lease works only on that cluster
- The cluster refuses clients that connect without a username and password
- A cluster can use only one user group, so Infisical can’t use a cluster that already has a user group of your own
Step 1: Create an IAM user for Infisical
Infisical uses an AWS IAM user to create the cluster’s user group and the users for each lease.1
In AWS, create an IAM user with the following policy. Replace
<region> and <account-id> with the region and AWS account ID of your cluster.2
Create an access key for the IAM user, and copy the access key ID and the secret access key.
Step 2: Create the dynamic secret
1
In your project, go to the environment and folder where you want the dynamic secret, then select Add New > Add Dynamic Secret.
2
Select AWS ElastiCache.
3
4
(Optional) Expand Modify ElastiCache Statements to change how Infisical creates each user:
Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.Allowed template variables are:
{{randomUsername}}: Random username string.{{unixTimestamp}}: Current Unix timestamp at the time of lease creation.{{identity.name}}: Name of the identity that is generating the lease.{{dynamicSecret.name}}: Name of the associated dynamic secret.{{dynamicSecret.type}}: Type of the associated dynamic secret.{{random N}}: Random string of N characters.
truncate: Truncates a string to a specified length.replace: Replaces a substring with another value.uppercase: Converts a string to uppercase.lowercase: Converts a string to lowercase.
The settings Infisical sends to AWS to create each user. To limit what a lease can do on the cluster, change
AccessString (for example, on ~app:* +@read allows read commands on keys that start with app:).5
Select Submit.Infisical checks that the IAM user can reach the cluster, then creates the cluster’s user group. ElastiCache takes up to a minute to finish creating the group.
Step 3: Create a lease
1
In the row for the dynamic secret, select Generate Lease.
2
Enter a Default TTL for the lease, then select Provision Lease.
3
Copy the
DB_USERNAME and DB_PASSWORD values that Infisical shows.ElastiCache takes about a minute to add a new user to the cluster. Until then, a login with the new password fails, so make your application retry the connection.
Revoke or renew a lease
Select the dynamic secret to see its leases:- Select Revoke lease to delete the lease’s user from the cluster before the lease expires
- Select Renew lease to extend the lease, up to the Max TTL of the dynamic secret
Clusters set up by earlier versions of Infisical
Earlier versions of Infisical attached one shared user group,infisical-managed-group-elasticache, to every cluster. If your cluster still uses that group, Infisical keeps using it for new leases, so your existing leases keep working.
To give the cluster its own user group, with the cluster access controls:
1
Remove the shared user group from the cluster. Existing leases for the cluster stop working.
2
Create a lease. Infisical creates the cluster’s own user group and asks you to try again in a minute.
3
Create the lease again. Infisical attaches the cluster’s user group to the cluster.
4
Revoke the cluster’s old leases, then create new leases for the applications that used them.
infisical-managed-group-elasticache anymore, you can delete the group in the ElastiCache console.
Troubleshooting
A lease fails with 'ElastiCache is still updating the user group for this cluster'
A lease fails with 'ElastiCache is still updating the user group for this cluster'
ElastiCache takes about a minute to create a cluster’s user group, and about a minute to add each new lease’s user. Wait a minute, then create the lease again.
Creating the dynamic secret fails because the cluster already uses a user group
Creating the dynamic secret fails because the cluster already uses a user group
A cluster can use only one user group, and Infisical needs its own group to create leases. Remove your user group from the cluster, or use a different cluster.
An application can't connect and gets 'NOAUTH Authentication required'
An application can't connect and gets 'NOAUTH Authentication required'
The cluster refuses clients that connect without a username and password. Configure the application to log in with the
DB_USERNAME and DB_PASSWORD of a lease.