> For the complete documentation index, see [llms.txt](https://docs.p0.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.p0.dev/integrations/resource-integrations/postgresql-new/installing-an-rds-database.md).

# Installing an RDS Database

## Installing an RDS database

Follow this guide to install P0 on an AWS-RDS-managed PostgreSQL database. P0 manages individual PostgreSQL instances, PostgreSQL clusters, and Aurora PostgreSQL clusters in the same manner.

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Before you begin, ensure you have:

* Admin access to the database
* IAM authentication enabled on the database
* AWS permissions that allow you to create IAM policies, and grant those policies to roles
* AWS permissions that allow you to create ECR repositories, add images to that repository, create Lambda functions, and create VPC endpoints and security groups within the database's VPC
* A P0 [AWS RDS](https://docs.p0.dev/~/changes/198/integrations/resource-integrations/aws/managed-services/aws-rds) integration installed on the VPC that hosts the database

### Installation <a href="#installation" id="installation"></a>

Follow these steps to install P0 on a PostgreSQL instance or cluster:

**Via the P0 app**

1. Navigate to **Integrations > PostgreSQL** in the P0 app
2. Select the **Access management** component
3. Click **Add instance**
4. Enter a unique identifier for the instance (this can be any value you like)
5. Choose **AWS RDS** hosting
   1. Enter the ARN of the AWS RDS instance
   2. Select the installed P0 AWS RDS VPC integration
6. Click **Next**
7. Run the supplied SQL command in the PostgreSQL database
8. Run the supplied Terraform to deploy the P0 connector
9. Click **Next**
10. If desired, configure the port and default database
11. Click **Finish**

**Via the P0 Terraform provider**

1. Run the following SQL in the PostgreSQL database to create the admin user. If the user already exists, you can skip the `CREATE USER` statement or ignore the error.

```sql
CREATE USER p0_iam_manager;
GRANT rds_iam TO p0_iam_manager;
GRANT rds_superuser TO p0_iam_manager;
```

2. Ensure you have configured the [P0 Terraform provider](https://registry.terraform.io/providers/p0-security/p0/latest/docs)
3. Use the [`p0_postgres_staged`](https://registry.terraform.io/providers/p0-security/p0/latest/docs/resources/postgres_staged) resource to begin integration install

```terraform
resource "p0_postgres_staged" "p0_postgres_cluster" {
  id = "exampleId"
  hosting = {
    type         = "aws-rds"
    instance_arn = <input>
    vpc_id = <input>
  }
}
```

4. Use the [p0-db/aws](https://registry.terraform.io/modules/p0-security/p0-db/aws/latest) module to set up your AWS environment

```terraform
module "p0_aws_pg_install" {
  source  = "p0-security/p0-db/aws"
  version = "0.5.1"

  rds_arn = <input>

  connector_security_group_id = <input>
  lambda_execution_role_name  = <input>
}
```

5. Use the [`p0_postgres`](https://registry.terraform.io/providers/p0-security/p0/latest/docs/resources/postgres) resource to finish integration install

```terraform
resource "p0_postgres" "p0_postgres_cluster" {
  depends_on = [module.p0_aws_pg_install]
  id         = resource.p0_postgres_staged.p0_postgres.id
  default_db = "postgres"
}
```

6. Run `terraform init` and `terraform apply`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.p0.dev/integrations/resource-integrations/postgresql-new/installing-an-rds-database.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
