A program to rotate the password of an RDS database accessed via a RDS proxy
Project description
rds-proxy-password-rotation
:warning: Work in progress :warning:
- add Terraform module
Python script for multi-user password rotation using RDS and RDS proxy. It supports credentials for the application and the RDS proxy.
We implemented this logic again, because current implementations
- have no tests
- have no release process
- are not published to PyPI
- have no Docker image available
- have no Terraform module available
Pre-requisites
-
Python 3.10 or later
-
For each db user:
-
Clone the user in the database and grant the necessary permissions. We suggest to add a
-clonesuffix to the username. -
Create a secret in AWS Secrets Manager with the following key-value pairs (for every user and its clone):
rotation_type: "AWS RDS"rotation_usernames: Optional. The list of usernames that a part of the rotation, e.g.["app_user", "app_user-clone"]. If not provided,usernameis used only.proxy_secret_ids: Optional. The list of ARNs of the secrets that are attached to the RDS Proxy, e.g.["arn:aws:secretsmanager:region:account-id:secret:secret-name"]. If not provided, the proxy credentials are not adjusted.database_host: The hostname of the databasedatabase_port: The port of the databasedatabase_name: The name of the databaseusername: The username for the userpassword: The password for the user
This credential will be used by the application to connect to the proxy. You may add additional key-value pairs as needed.
-
-
If you are using RDS Proxy:
- Create a secret in AWS Secrets Manager with the following key-value pairs:
username: The username for the user that the proxy will use to connect to the databasepassword: The password for the user that the proxy will use to connect to the database
- Attach the secret to the RDS Proxy.
- Create a secret in AWS Secrets Manager with the following key-value pairs:
-
The docker image can be pulled from GHCR:
docker pull ghcr.io/Hapag-Lloyd/rds-proxy-password-rotation:edge
:warning: The
edgetag is used for the latest build. You SHOULD use a specific version tag in production.
Architecture
Challenges with RDS and RDS Proxy
RDS Proxy is a fully managed, highly available database proxy for Amazon Relational Database Service (RDS) that makes applications more scalable, more resilient to database failures, and more secure. It allows applications to pool and share database connections to improve efficiency and reduce the load on your database instances.
However, RDS Proxy does not support multi-user password rotation out of the box. This script provides a solution to this problem.
Using an RDS Proxy requires a secret in AWS Secrets Manager with the credentials to connect to the database. This secret is used by the proxy to connect to the database. The proxy allows the application to connect to the database using the same credentials and then forwards the requests to the database with the same credentials. This means that the credentials in the secret must be valid in the database at all times. But what if you want to rotate the password for the user that the proxy uses to connect to the database? You can’t just update the secret in SecretsManager because the proxy will stop working as soon as the secret is updated. And you can’t just update the password in the database because the proxy will stop working as soon as the password is updated.
Why password rotation is a good practice
Password rotation is a good idea for several reasons:
- Enhanced Security: Regularly changing passwords reduces the risk of unauthorized access due to compromised credentials.
- Mitigates Risk: Limits the time window an attacker has to exploit a stolen password.
- Compliance: Many regulatory standards and security policies require periodic password changes.
- Reduces Impact of Breaches: If a password is compromised, rotating it ensures that the compromised password is no longer valid.
- Encourages Good Practices: Promotes the use of strong, unique passwords and discourages password reuse.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rds_proxy_password_rotation-0.6.191.tar.gz.
File metadata
- Download URL: rds_proxy_password_rotation-0.6.191.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be5c5f20571d3594e9ed4e30ee667639eae21886d306584ed644a292e74f532e
|
|
| MD5 |
578f8ada2918b130092bb49bb9e87edc
|
|
| BLAKE2b-256 |
c794d270b64fd53da7d0465337e546a29ce88d385925f1f9b67e89d14e5a3bb9
|
Provenance
The following attestation bundles were made for rds_proxy_password_rotation-0.6.191.tar.gz:
Publisher:
pypi_publish.yml on Hapag-Lloyd/rds-proxy-password-rotation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rds_proxy_password_rotation-0.6.191.tar.gz -
Subject digest:
be5c5f20571d3594e9ed4e30ee667639eae21886d306584ed644a292e74f532e - Sigstore transparency entry: 732628197
- Sigstore integration time:
-
Permalink:
Hapag-Lloyd/rds-proxy-password-rotation@4fe4270a4cf2167929d3aaf54bb86b7db4220e65 -
Branch / Tag:
refs/tags/0.6.191 - Owner: https://github.com/Hapag-Lloyd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@4fe4270a4cf2167929d3aaf54bb86b7db4220e65 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rds_proxy_password_rotation-0.6.191-py3-none-any.whl.
File metadata
- Download URL: rds_proxy_password_rotation-0.6.191-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a83890419164fb71e36d36d2c509a83e78926bc33870323c3cfae7e9e7bc044
|
|
| MD5 |
08575c64ea61ed80dd18a3dd70cb20e3
|
|
| BLAKE2b-256 |
441c1e6799d2f142231858ac35f228e75c564356a798ea294cde671df6334c54
|
Provenance
The following attestation bundles were made for rds_proxy_password_rotation-0.6.191-py3-none-any.whl:
Publisher:
pypi_publish.yml on Hapag-Lloyd/rds-proxy-password-rotation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rds_proxy_password_rotation-0.6.191-py3-none-any.whl -
Subject digest:
7a83890419164fb71e36d36d2c509a83e78926bc33870323c3cfae7e9e7bc044 - Sigstore transparency entry: 732628199
- Sigstore integration time:
-
Permalink:
Hapag-Lloyd/rds-proxy-password-rotation@4fe4270a4cf2167929d3aaf54bb86b7db4220e65 -
Branch / Tag:
refs/tags/0.6.191 - Owner: https://github.com/Hapag-Lloyd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@4fe4270a4cf2167929d3aaf54bb86b7db4220e65 -
Trigger Event:
release
-
Statement type: