KBAISE/ for lovable
Library
Docs

Connect your app to Amazon Redshift

about 30 minBuildingchecked 2h agoOfficial page
The short version

You can connect your Lovable app to Amazon Redshift, a cloud data warehouse, to run SQL queries and get results. This lets you build things like dashboards and reports using your warehouse data without managing complex database connections.

Anyone who wants to build apps or tools in Lovable that use data stored in Amazon Redshift.

Do this, in order

  1. 1

    Go to the AWS IAM console and create a new IAM user, for example, 'lovable-redshift'.

    This dedicated user will be used by Lovable to securely access your Redshift data.

  2. 2

    Create and attach a policy to this IAM user with specific permissions for Redshift Data API actions, credential fetching, and optionally discovering Serverless workgroups.

    This policy ensures Lovable has only the necessary access to interact with Redshift without over-privileging the connection. Make sure to include the correct credential-fetch action based on your Redshift setup (Serverless or Provisioned).

  3. 3

    In the IAM user's 'Security credentials' tab, generate an access key and save both the 'Access key ID' and 'Secret access key'.

    These keys are essential for Lovable to authenticate with your AWS account and access Redshift. Treat the secret key like a password.

  4. 4

    In Lovable, go to 'Connectors', select 'Amazon Redshift', and click 'Add connection'.

    This starts the process of setting up the connection within your Lovable workspace.

  5. 5

    Fill in the connection details: a display name, deployment type (Serverless or Provisioned), AWS region, the Access key ID and Secret access key you saved, and your specific Redshift workgroup or cluster identifier, database, and optionally a database user.

    These details tell Lovable how to find and connect to your specific Redshift instance using the credentials you provided.

  6. 6

    Choose who in your Lovable workspace can use this connection, starting with just yourself, specific members, or the entire workspace.

    This controls access to the Redshift connection within Lovable, ensuring only authorized individuals or projects can use it.

  7. 7

    Click 'Connect' to finalize the setup.

    Lovable will verify the credentials, and once successful, your apps can start running SQL queries against your Redshift warehouse.

  8. 8

    After connecting, if you want to ensure the connection is read-only, find the database user your connection runs as (e.g., 'IAM:lovable-redshift' or a named user) and grant it only 'SELECT' permissions on the necessary schemas in Redshift.

    IAM permissions control what the connection can do at the API level, but database grants control what SQL queries can actually modify data within Redshift. This prevents accidental writes or deletions.

  9. 9

    Also, revoke 'CREATE' on the 'public' schema and 'TEMP' on the database from 'PUBLIC' in Redshift to prevent users from creating new tables or temporary tables by default.

    This is a security best practice to further restrict what any user, including your Lovable connection, can do in your Redshift database.

Paste this into your project

Connect my Lovable app to Amazon Redshift. I need to run SQL queries and read results from my data warehouse. I've already created an IAM user with the necessary permissions and have my access keys ready. My Redshift is a Serverless workgroup named 'my-workgroup' in 'us-east-1', and I want to connect to the 'dev' database. Please guide me through the Lovable connection process.

Words decoded

Cloud data warehouse
A specialized database service that stores very large amounts of data and is optimized for fast analysis, all hosted on the internet by a provider like Amazon.
SQL queries
Instructions written in a special language (Structured Query Language) that tell a database what data to find, change, or organize.
IAM user
An identity in Amazon Web Services (AWS) that represents a person or an application, with specific permissions to access AWS resources.
IAM credentials
The username and password (or access key ID and secret access key) for an IAM user, used to prove who you are to AWS.
Redshift Data API
A way for applications to send SQL commands to Amazon Redshift and get results back, without needing a direct, constant database connection.
Provisioned cluster
A traditional setup for Amazon Redshift where you choose and manage specific computing resources (servers) for your data warehouse.
Serverless workgroup
A newer, more automated setup for Amazon Redshift where Amazon automatically manages the computing resources, so you don't have to pick server sizes or manage them directly.
Database grants
Specific permissions given to a user within a database that control what actions they can perform (like reading data, changing data, or creating new tables).
AWS region
A specific geographic area where Amazon Web Services has data centers, like 'US East (N. Virginia)'.

Where people get stuck

  • Forgetting to save your 'Secret access key' when creating an IAM user, as it's shown only once.
  • Not matching the correct credential-fetch action in your IAM policy to your Redshift deployment type (Serverless or Provisioned) and whether you use a specific database user.
  • Assuming the Lovable connection is read-only by default; you must explicitly set read-only permissions using database grants within Redshift.
  • Not creating the database user in Redshift beforehand if you specify one for a Provisioned cluster, as the Data API won't create it for you.
  • Forgetting to double-quote 'IAM:' database user names in SQL, which will cause syntax errors.
  • Not repeating read-only grants in every database the connection can reach, as grants are database-specific.
  • Leaving default 'CREATE' and 'TEMP' permissions on the 'public' schema and database, which can allow unintended actions even with 'SELECT' only grants.

The short version, steps, decoder and prompt on this page are written automatically from Lovable's own documentation and can lag or misread it. The official page is always the authority.