Provision Amazon RDS databases - MySQL/Postgres
ops.json
:ops.json
in the root directory of Github repo
you’ve connected for the service.
ops.json
here.id
- Alphanumeric string. Must be unique amongst the instances you’ve declared above. Changing this string will
replace the original instance with new one.prefix
- Alphanumeric string. Will be used as a prefix in the name of your instance. Changing this string will
replace the original instance with new instance.engine
- Provide either postgres
or mysql
. Default: postgres
version
- Pick a version for your postgres or mysql database. Ensure RDS supports it, by referring to AWS docs -
Postgres /
MySQL. Default: ""
- so
it will provision latest version as decided by AWS.storage_gb
- Specify the amount of storage you need in GB. You can set one value and yet change this later.
Default: 10
instance_type
- Specify any class of instance in the following groups - “db.t4g.”, “db.t3.”, “db.m5.*”. Refer to
AWS docs for available sizes. Default: db.t4g.small
publicly_accessible
- Set it to true
if you need this database to be available publicly on the internet. You
would want this to be false
most of the time. Default: false
multi_az
- Specifies if the RDS instance is multi-AZmaintenance_window
- The window to perform maintenance in. Syntax: “ddd:hh24:mi-ddd:hh24:mi”. Eg:
“Mon:00:00-Mon:03:00”. See
RDS Maintenance Window docs
for more information.exports
- Set of key value pairs. Keys are the ENVIRONMENT VARS we will pass to your code / containers. Values are
the properties of the RDS instance provisioned. See below for available properties.id
or prefix
string will delete & replace the original RDS instance with new one.exports
:
$name
- Name of the RDS instance$arn
- Amazon resource name of the RDS instance. Eg., arn:rds:..
$endpoint
- The connection endpoint in address:port
format.$address
- Specifies the DNS address of the DB instance.$dbName
- Specifies the database name created under the RDS instance. This is auto-created for you so you won’t
specific this name explicitly anywhere in your config.$username
- Specifics the username of the database user. You will typically use this in your code’s Db connection
string to access the database $dbName
.$passwordArn
- Password of the user $username
is automatically generated, encrypted and maintained by RDS in AWS
secret manager. Your code has to read the password from the AWS secret manager using this $passwordArn
.ops.json
at the root of the git repository, it will be processed if a corresponding service in
any of your active environment points at the same repository as source and when a deployment is triggered.
ops.json
is parsed for processing.
Resources declared in the dependencies
object will be provisioned before your code starts to run.id
are provisioned only once for the life of the service. And updated when there is a change in
one of the properties above.exports
object will be passed as enviroment variables to your service.10.0.0.0/16
(Your environment’s VPC CIDR IP range)5432
(for Postgres) or 3306
(for MySQL)TCP
DB_*
environment variables to connect and
access the database.
Repeat the above process for each RDS instance you want to create for each environment - test, staging, production,
etc.,
That’s it!
DB_*
environment variables to connect and
access the database.
That’s it. 🎉