RDS
A class for creating an RDS instance in AWS.
Like all Resources, this class configures itself across multiple Environments.
For more information see the official documentation.
Example Usage
1import launchflow as lf
2
3# Automatically creates / connects to an RDS cluster in your AWS account
4rds_instance = lf.aws.RDS("my-db", engine_version=lf.aws.RDSEngineVersion.POSTGRES16)
initialization
Create a new RDS resource.
Args:
name (str): The name of the RDS cluster.allocated_storage_gb (int): The amount of storage to allocate for the cluster in GB. Defaults to 20 GB.highly_available (Optional[bool]): Whether the database should be made available in multiple availability zones. Defaults toFalsefor development environments andTruefor production.instance_class (Optional[str]): The instance class to use for the RDS cluster. Defaults todb.t4g.microfor development environments anddb.r5.largefor production.publicly_accessible (Optional[bool]): Whether the database should be publicly accessible. Defaults toTruefor development environments andFalsefor production.engine_version (RDSEngineVersion): The engine version to use. Defaults toRDSEngineVersion.POSTGRES16.
query
1RDS.query(query: str)
Executes a SQL query on the Postgres instance running on the RDS cluster.
Args:
query (str): The SQL query to execute.
Returns:
- The result of the query if it returns rows, otherwise None.
Example usage:
1import launchflow as lf
2
3postgres = lf.aws.RDS("my-pg-db")
4
5# Executes a query on the Postgres instance running on the RDS cluster
6postgres.query("SELECT 1")
NOTE: This method is not recommended for production use. Use sqlalchemy_engine instead.
sqlalchemy_engine
1RDS.sqlalchemy_engine(**engine_kwargs)
Returns a SQLAlchemy engine for connecting to the RDS SQL Postgres instance.
Args:
**engine_kwargs: Additional keyword arguments to pass tosqlalchemy.create_engine.
Example usage:
1import launchflow as lf
2
3postgres = lf.aws.RDS("my-pg-db")
4
5# Creates a SQLAlchemy engine for connecting to the RDS SQL Postgres instance
6engine = postgres.sqlalchemy_engine()
7
8with engine.connect() as connection:
9 print(connection.execute("SELECT 1").fetchone()) # prints (1,)

