PostgreSQL Credentials
Learn how to automatically rotate PostgreSQL credentials.
Prerequisites
-
Create a PostgreSQL Connection with the required Secret Rotation permissions
-
Create two designated database users for Infisical to rotate the credentials for. Be sure to grant each user login permissions for the desired database with the necessary privileges their use case will require.
An example creation statement might look like:
To learn more about PostgreSQL’s permission system, please visit their documentation.
Create a PostgreSQL Credentials Rotation in Infisical
-
Navigate to your Secret Manager Project’s Dashboard and select Add Secret Rotation from the actions dropdown.
-
Select the PostgreSQL Credentials option.
-
Select the PostgreSQL Connection to use and configure the rotation behavior. Then click Next.
- PostgreSQL Connection - the connection that will perform the rotation of the configured database user credentials.
- Rotation Interval - the interval, in days, that once elapsed will trigger a rotation.
- Rotate At - the local time of day when rotation should occur once the interval has elapsed.
- Auto-Rotation Enabled - whether secrets should automatically be rotated once the rotation interval has elapsed. Disable this option to manually rotate secrets or pause secret rotation.
-
Input the usernames of the database users created above that will be used for rotation. Then click Next.
- Database Username 1 - the username of the first user that will be used for rotation.
- Database Username 2 - the username of the second user that will be used for rotation.
-
Specify the secret names that the active credentials should be mapped to. Then click Next.
- Username - the name of the secret that the active username will be mapped to.
- Password - the name of the secret that the active password will be mapped to.
-
Give your rotation a name and description (optional). Then click Next.
- Name - the name of the secret rotation configuration. Must be slug-friendly.
- Description (optional) - a description of this rotation configuration.
-
Review your configuration, then click Create Secret Rotation.
-
Your PostgreSQL Credentials are now available for use via the mapped secrets.
-
Navigate to your Secret Manager Project’s Dashboard and select Add Secret Rotation from the actions dropdown.
-
Select the PostgreSQL Credentials option.
-
Select the PostgreSQL Connection to use and configure the rotation behavior. Then click Next.
- PostgreSQL Connection - the connection that will perform the rotation of the configured database user credentials.
- Rotation Interval - the interval, in days, that once elapsed will trigger a rotation.
- Rotate At - the local time of day when rotation should occur once the interval has elapsed.
- Auto-Rotation Enabled - whether secrets should automatically be rotated once the rotation interval has elapsed. Disable this option to manually rotate secrets or pause secret rotation.
-
Input the usernames of the database users created above that will be used for rotation. Then click Next.
- Database Username 1 - the username of the first user that will be used for rotation.
- Database Username 2 - the username of the second user that will be used for rotation.
-
Specify the secret names that the active credentials should be mapped to. Then click Next.
- Username - the name of the secret that the active username will be mapped to.
- Password - the name of the secret that the active password will be mapped to.
-
Give your rotation a name and description (optional). Then click Next.
- Name - the name of the secret rotation configuration. Must be slug-friendly.
- Description (optional) - a description of this rotation configuration.
-
Review your configuration, then click Create Secret Rotation.
-
Your PostgreSQL Credentials are now available for use via the mapped secrets.
To create a PostgreSQL Credentials Rotation, make an API request to the Create PostgreSQL Credentials Rotation API endpoint.
Sample request
Sample response
Was this page helpful?