When creating an RDS instance in MiniStack, it starts a real database container and returns the actual connection endpoint. You can connect directly to this instance using standard database drivers (e.g., psycopg2 for PostgreSQL).
Supported engines include: postgres, mysql, mariadb, aurora-postgresql, and aurora-mysql.
Note: For Aurora clusters, all members share a single database container. The reader endpoint resolves to the same process as the writer, so writes sent to the reader will be accepted.
import boto3
import psycopg2 # pip install psycopg2-binary
# Initialize client pointing to MiniStack
rds = boto3.client("rds", endpoint_url="http://localhost:4566",
aws_access_key_id="test", aws_secret_access_key="test", region_name="us-east-1")
# Create the instance
resp = rds.create_db_instance(
DBInstanceIdentifier="mydb",
DBInstanceClass="db.t3.micro",
Engine="postgres",
MasterUsername="admin",
MasterUserPassword="password",
DBName="appdb",
AllocatedStorage=20,
)
# Extract endpoint and connect directly
endpoint = resp["DBInstance"]["Endpoint"]
conn = psycopg2.connect(
host=endpoint["Address"], # localhost
port=endpoint["Port"], # auto-assigned
user="admin",
password="password",
dbname="appdb",
)