# Set up databases

All applications in an environment share a common database cluster.

The database cluster set up for your environment is `{Environment}-main`, and the default database is `{Environment}-main-one`.

## Step 1: Add and configure the `databases` package

```bash title="repo-iac/environments/dev/"
ok pkg add databases
```

Update `package-config.yml` with your preferences.

To use a **Serverless** database cluster (default):

```yaml title="repo-iac/environments/dev/databases/package-config.yml"
Serverless:
  Enable: true
```

To use a **traditional** database cluster:

```yaml title="repo-iac/environments/dev/databases/package-config.yml"
Serverless:
  Enable: false
```

## Step 2: Install the package

```bash title="repo-iac/environments/dev/databases/"
ok pkg install
```

## Step 3: Initialize and apply the `databases` stack

```bash title="repo-iac/environments/dev/databases/"
terraform init
terraform apply
```

## Step 4: Verify

=== "AWS CLI"

    Run the following command:

    ```bash
    aws rds describe-db-instances | jq '.DBInstances[].DBInstanceIdentifier'
    ```

    The output list should contain the name of the database instance you just created.

=== "AWS console"

    Sign in to the AWS console and navigate to **RDS**. Select **Databases** in the left-hand menu.

    The list should contain the name of the database cluster you just created.

---

--8<-- "includes/commit.md"

You're done with the Database setup.

## Next step

Set up [GitHub OIDC](set-up-github-oidc.md).
