Skip to content

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: Create a new configuration file

Create a new configuration file for databases:

repo-iac/environments/dev/_config/databases.yml
StackName: "databases"
Serverless:
  Enable: true

Enabling Serverless will create a Serverless database cluster. If you want to create a traditional database cluster, set Enable to false.

Step 2: Add and install the databases package

Run the following command in the repo-iac/environments/dev/ directory:

repo-iac/environments/dev/
ok pkg add databases

This will add the package you want to install to packages.yml. If you want to know more about how this works, read the reference documentation for packages.yml.

Then, run the following command to install the package:

repo-iac/environments/dev/
ok pkg install databases

Step 3: Initialize and apply the databases stack

repo-iac/environments/dev
cd databases/
terraform init
terraform apply

Step 4: Verify

Run the following command:

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

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

Login 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.


Commit your files

At this stage it is a good idea to commit your files.

Next step

Set up certificates.