Skip to content

Commit b7b5be5

Browse files
authored
Postgres to Aurora rename (#31)
* Initial commit * Fixing out_dotenv * Fixing var * Cosmetics
1 parent 38dd73b commit b7b5be5

File tree

11 files changed

+225
-217
lines changed

11 files changed

+225
-217
lines changed

README.md

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
1. [Certificates](#certificate-inputs)
5757
1. [Load Balancer](#load-balancer-inputs)
5858
1. [EFS](#efs-inputs)
59-
1. [RDS](#rds-inputs)
59+
1. [Amazon Aurora Inputs](#aurora-inputs)
6060
1. [Docker](#docker-inputs)
6161
6262
The following inputs can be used as `step.with` keys
@@ -192,24 +192,24 @@ The following inputs can be used as `step.with` keys
192192
<hr/>
193193
<br/>
194194

195-
#### **RDS Inputs**
195+
#### **Aurora Inputs**
196196
| Name | Type | Description |
197197
|------------------|---------|------------------------------------|
198-
| `aws_postgres_enable` | Boolean | Set to `true` to enable a postgres database. |
199-
| `aws_postgres_engine` | String | Which Database engine to use. Default is `aurora-postgresql`.|
200-
| `aws_postgres_engine_version` | String | Specify Postgres version. More information [here](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Updates.20180305.html). Default is `11.17`. |
201-
| `aws_postgres_database_group_family` | String | Specify aws database group family. Default is `aurora-postgresql11`. See [this](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/rds/create-db-parameter-group.html).|
202-
| `aws_postgres_instance_class` | String | Define the size of the instances in the DB cluster. Default is `db.t3.medium`. |
203-
| `aws_postgres_security_group_name` | String | The name of the Postgres security group. Defaults to `SG for ${aws_resource_identifier} - PG`. |
204-
| `aws_postgres_subnets` | String | Specify which subnets to use as a list of strings. Example: `i-1234,i-5678,i-9101`. |
205-
| `aws_postgres_cluster_name` | String | Specify a cluster name. Will be created if it does not exist. Defaults to `aws_resource_identifier`. |
206-
| `aws_postgres_database_name` | String | Specify a database name. Will be created if it does not exist. Defaults to `aws_resource_identifier`. |
207-
| `aws_postgres_database_port` | String | Specify a listening port for the database. Default is `5432`.|
208-
| `aws_postgres_restore_snapshot` | String | Restore a snapshot to the DB. Should be set only once. Changes in this value will destroy and recreate the database completely. |
209-
| `aws_postgres_snapshot_name` | String | Specify a database name. Will be created if it does not exist. Won't overwrite. |
210-
| `aws_postgres_snapshot_overwrite` | Boolean | Set to true to overwrite the snapshot. |
211-
| `aws_postgres_database_protection` | Boolean | Protects the database from deletion. Default is `false`.|
212-
| `aws_postgres_database_final_snapshot` | Boolean | Creates a snapshot before deletion. If a string is passed, it will be used as snapsthot name. Defaults to `false`.|
198+
| `aws_aurora_enable` | Boolean | Set to `true` to enable an [Aurora database](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_AuroraOverview.html). (Postgres or MySQL). |
199+
| `aws_aurora_engine` | String | Which Database engine to use. Default is `aurora-postgresql`.|
200+
| `aws_aurora_engine_version` | String | Specify database version. More information [Postgres](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Updates.20180305.html) or [MySQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraMySQLReleaseNotes/Welcome.html). Default is `11.17`. (Postgres) |
201+
| `aws_aurora_database_group_family` | String | Specify aws database group family. Default is `aurora-postgresql11`. See [this](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/rds/create-db-parameter-group.html).|
202+
| `aws_aurora_instance_class` | String | Define the size of the instances in the DB cluster. Default is `db.t3.medium`. |
203+
| `aws_aurora_security_group_name` | String | The name of the database security group. Defaults to `SG for ${aws_resource_identifier} - Aurora`. |
204+
| `aws_aurora_subnets` | String | Specify which subnets to use as a list of strings. Example: `i-1234,i-5678,i-9101`. |
205+
| `aws_aurora_cluster_name` | String | Specify a cluster name. Will be created if it does not exist. Defaults to `aws_resource_identifier`. |
206+
| `aws_aurora_database_name` | String | Specify a database name. Will be created if it does not exist. Defaults to `aws_resource_identifier`. |
207+
| `aws_aurora_database_port` | String | Specify a listening port for the database. Default is `5432`.|
208+
| `aws_aurora_restore_snapshot` | String | Restore a snapshot to the DB. Should be set only once. Changes in this value will destroy and recreate the database completely. |
209+
| `aws_aurora_snapshot_name` | String | Specify a database name. Will be created if it does not exist. Won't overwrite. |
210+
| `aws_aurora_snapshot_overwrite` | Boolean | Set to true to overwrite the snapshot. |
211+
| `aws_aurora_database_protection` | Boolean | Protects the database from deletion. Default is `false`.|
212+
| `aws_aurora_database_final_snapshot` | Boolean | Creates a snapshot before deletion. If a string is passed, it will be used as snapsthot name. Defaults to `false`.|
213213
<hr/>
214214
<br/>
215215

@@ -284,9 +284,11 @@ An example EFS Zone mapping;
284284
}
285285
```
286286
287-
## Adding external Postgres database (AWS RDS)
287+
## Adding external Aurora database (AWS RDS)
288288
289-
If `aws_postgres_enable` is set to `true`, this action will deploy an RDS cluster for Postgres.
289+
If `aws_aurora_enable` is set to `true`, this action will deploy a RDS Aurora cluster using Postgres as a default.
290+
291+
See [this Terraform provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster) and [this other AWS doc](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/rds/create-db-parameter-group.html) to set up most of the variables.
290292
291293
### Environment variables
292294
The following environment variables are added to the `.env` file in your app's `docker-compose.yaml` file.
@@ -304,17 +306,18 @@ services:
304306
The available environment variables are:
305307
| Variable | Description |
306308
|----------|-------------|
307-
| `POSTGRES_CLUSTER_ENDPOINT` (and `PGHOST`) | Writer endpoint for the cluster |
308-
| `POSTGRES_CLUSTER_PORT` (and `PGPORT`) | The database port |
309-
| `POSTGRES_CLUSTER_MASTER_PASSWORD` (and `PG_PASSWORD`) | database root password |
310-
| `POSTGRES_CLUSTER_MASTER_USERNAME` (and `PG_USER`) | The database master username |
311-
| `POSTGRES_CLUSTER_DATABASE_NAME` (and `PGDATABASE`) | Name for an automatically created database on cluster creation |
312-
| `POSTGRES_CLUSTER_ARN` | Amazon Resource Name (ARN) of cluster |
313-
| `POSTGRES_CLUSTER_ID` | The RDS Cluster Identifier |
314-
| `POSTGRES_CLUSTER_RESOURCE_ID` | The RDS Cluster Resource ID |
315-
| `POSTGRES_CLUSTER_READER_ENDPOINT` | A read-only endpoint for the cluster, automatically load-balanced across replicas |
316-
| `POSTGRES_CLUSTER_ENGINE_VERSION_ACTUAL` | The running version of the cluster database |
317-
| `POSTGRES_CLUSTER_HOSTED_ZONE_ID`| The Route53 Hosted Zone ID of the endpoint |
309+
| `AURORA_CLUSTER_ENGINE` (and `DBA_ENGINE`) | Engine name - ( mysql/postgres ) |
310+
| `AURORA_CLUSTER_ENDPOINT` (and `DBA_HOST`) | Writer endpoint for the cluster |
311+
| `AURORA_CLUSTER_PORT` (and `DBA_PORT`) | The database port |
312+
| `AURORA_CLUSTER_MASTER_PASSWORD` (and `DBA_PASSWORD`) | database root password |
313+
| `AURORA_CLUSTER_MASTER_USERNAME` (and `DBA_USER`) | The database master username |
314+
| `AURORA_CLUSTER_DATABASE_NAME` (and `DBA_NAME`) | Name for an automatically created database on cluster creation |
315+
| `AURORA_CLUSTER_ARN` | Amazon Resource Name (ARN) of cluster |
316+
| `AURORA_CLUSTER_ID` | The RDS Cluster Identifier |
317+
| `AURORA_CLUSTER_RESOURCE_ID` | The RDS Cluster Resource ID |
318+
| `AURORA_CLUSTER_READER_ENDPOINT` | A read-only endpoint for the cluster, automatically load-balanced across replicas |
319+
| `AURORA_CLUSTER_ENGINE_VERSION_ACTUAL` | The running version of the cluster database |
320+
| `AURORA_CLUSTER_HOSTED_ZONE_ID`| The Route53 Hosted Zone ID of the endpoint |
318321
319322
### AWS Root Certs
320323
The AWS root certificate is downloaded and accessible via the `rds-combined-ca-bundle.pem` file in root of your app repo/directory.
@@ -327,11 +330,11 @@ const { Client } = require('pg')
327330
328331
// set up client
329332
const client = new Client({
330-
host: process.env.PGHOST,
331-
port: process.env.PGPORT,
332-
user: process.env.PG_USER,
333-
password: process.env.PG_PASSWORD,
334-
database: process.env.PGDATABASE,
333+
host: process.env.DBA_HOST,
334+
port: process.env.DBA_PORT,
335+
user: process.env.DBA_USER,
336+
password: process.env.DBA_PASSWORD,
337+
database: process.env.DBA_NAME,
335338
ssl: {
336339
ca: fs.readFileSync('rds-combined-ca-bundle.pem').toString()
337340
}
@@ -345,12 +348,12 @@ await client.end();
345348
console.log(`Hello SQL timestamp: ${result.rows[0].now}`);
346349
```
347350

348-
### Postgres Infrastructure and Cluster Details
351+
### Aurora Infrastructure and Cluster Details
349352
Specifically, the following resources will be created:
350353
- AWS Security Group
351354
- AWS Security Group Rule - Allows access to the cluster's db port: `5432`
352-
- AWS RDS Aurora Postgres
353-
- Includes a single database (set by the input: `aws_postgres_database_name`. defaults to `root`)
355+
- AWS RDS Aurora
356+
- Includes a single database (set by the input: `aws_aurora_database_name`. defaults to `root`)
354357

355358
Additional details about the cluster that's created:
356359
- Automated backups (7 Days)
@@ -359,7 +362,7 @@ Additional details about the cluster that's created:
359362
- Monitoring enabled
360363
- Sends logs to AWS Cloudwatch
361364

362-
> _**For more details**, see [operations/deployment/terraform/postgres.tf](operations/deployment/terraform/postgres.tf)_
365+
> _**For more details**, see [link-to-be-updated](operations/deployment/terraform/postgres.tf)_
363366
364367
## Made with BitOps
365368
[BitOps](https://bitops.sh) allows you to define Infrastructure-as-Code for multiple tools in a central place. This action uses a BitOps [Operations Repository](https://bitops.sh/operations-repo-structure/) to set up the necessary Terraform and Ansible to create infrastructure and deploy to it.

action.yaml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -253,49 +253,49 @@ inputs:
253253
required: false
254254

255255
# AWS RDS
256-
aws_postgres_enable:
256+
aws_aurora_enable:
257257
description: 'Set to "true" to enable a postgres database'
258258
required: false
259-
aws_postgres_engine:
259+
aws_aurora_engine:
260260
description: 'Which Database engine to use'
261261
required: false
262-
aws_postgres_engine_version:
262+
aws_aurora_engine_version:
263263
description: 'Specify Postgres version'
264264
required: false
265-
aws_postgres_database_group_family:
265+
aws_aurora_database_group_family:
266266
description: 'Postgres database group family'
267267
required: false
268-
aws_postgres_instance_class:
268+
aws_aurora_instance_class:
269269
description: 'Define the size of the instances in the DB cluster'
270270
required: false
271-
aws_postgres_security_group_name:
271+
aws_aurora_security_group_name:
272272
description: 'The name of the Postgres security group'
273273
required: false
274-
aws_postgres_subnets:
274+
aws_aurora_subnets:
275275
description: 'Specify which subnets to use as a list of strings. Example: `i-1234,i-5678,i-9101`'
276276
required: false
277-
aws_postgres_cluster_name:
277+
aws_aurora_cluster_name:
278278
description: 'Specify a cluster name. Will be created if it does not exist'
279279
required: false
280-
aws_postgres_database_name:
280+
aws_aurora_database_name:
281281
description: 'Specify a database name. Will be created if it does not exist'
282282
required: false
283-
aws_postgres_database_port:
283+
aws_aurora_database_port:
284284
description: 'Postgres database port'
285285
required: false
286-
aws_postgres_restore_snapshot:
286+
aws_aurora_restore_snapshot:
287287
description: 'Restore a snapshot to the DB. Should be used only once. Changes in this value will destroy and recreate the database completely.'
288288
required: false
289-
aws_postgres_snapshot_name:
289+
aws_aurora_snapshot_name:
290290
description: 'Takes a snapshot of the cluster using that name. If none definded, no snapshot will be made. If snap already exists, no new one will be created.'
291291
required: false
292-
aws_postgres_snapshot_overwrite:
292+
aws_aurora_snapshot_overwrite:
293293
description: 'If the snapshot name is the same as an existing one, will destroy and create a new one.'
294294
required: false
295-
aws_postgres_database_protection:
295+
aws_aurora_database_protection:
296296
description: 'Protects the database from deletion.'
297297
required: false
298-
aws_postgres_database_final_snapshot:
298+
aws_aurora_database_final_snapshot:
299299
description: 'Generates a snapshot of the database before deletion.'
300300
required: false
301301

@@ -500,21 +500,21 @@ runs:
500500
AWS_EFS_EC2_MOUNT_POINT: ${{ inputs.aws_efs_ec2_mount_point }}
501501

502502
# AWS RDS
503-
AWS_POSTGRES_ENABLE: ${{ inputs.aws_postgres_enable }}
504-
AWS_POSTGRES_ENGINE: ${{ inputs.aws_postgres_engine }}
505-
AWS_POSTGRES_ENGINE_VERSION: ${{ inputs.aws_postgres_engine_version }}
506-
AWS_POSTGRES_DATABASE_GROUP_FAMILY: ${{ inputs.aws_postgres_database_group_family }}
507-
AWS_POSTGRES_INSTANCE_CLASS: ${{ inputs.aws_postgres_instance_class }}
508-
AWS_POSTGRES_SECURITY_GROUP_NAME: ${{ inputs.aws_postgres_security_group_name }}
509-
AWS_POSTGRES_SUBNETS: ${{ inputs.aws_postgres_subnets }}
510-
AWS_POSTGRES_CLUSTER_NAME: ${{ inputs.aws_postgres_cluster_name }}
511-
AWS_POSTGRES_DATABASE_NAME: ${{ inputs.aws_postgres_database_name }}
512-
AWS_POSTGRES_DATABASE_PORT: ${{ inputs.aws_postgres_database_port}}
513-
AWS_POSTGRES_RESTORE_SNAPSHOT: ${{ inputs.aws_postgres_restore_snapshot }}
514-
AWS_POSTGRES_SNAPSHOT_NAME: ${{ inputs.aws_postgres_snapshot_name }}
515-
AWS_POSTGRES_SNAPSHOT_OVERWRITE: ${{ inputs.aws_postgres_snapshot_overwrite }}
516-
AWS_POSTGRES_DATABASE_PROTECTION: ${{ inputs.aws_postgres_database_protection }}
517-
AWS_POSTGRES_DATABASE_FINAL_SNAPSHOT: ${{ inputs.aws_postgres_database_final_snapshot }}
503+
AWS_AURORA_ENABLE: ${{ inputs.aws_aurora_enable }}
504+
AWS_AURORA_ENGINE: ${{ inputs.aws_aurora_engine }}
505+
AWS_AURORA_ENGINE_VERSION: ${{ inputs.aws_aurora_engine_version }}
506+
AWS_AURORA_DATABASE_GROUP_FAMILY: ${{ inputs.aws_aurora_database_group_family }}
507+
AWS_AURORA_INSTANCE_CLASS: ${{ inputs.aws_aurora_instance_class }}
508+
AWS_AURORA_SECURITY_GROUP_NAME: ${{ inputs.aws_aurora_security_group_name }}
509+
AWS_AURORA_SUBNETS: ${{ inputs.aws_aurora_subnets }}
510+
AWS_AURORA_CLUSTER_NAME: ${{ inputs.aws_aurora_cluster_name }}
511+
AWS_AURORA_DATABASE_NAME: ${{ inputs.aws_aurora_database_name }}
512+
AWS_AURORA_DATABASE_PORT: ${{ inputs.aws_aurora_database_port}}
513+
AWS_AURORA_RESTORE_SNAPSHOT: ${{ inputs.aws_aurora_restore_snapshot }}
514+
AWS_AURORA_SNAPSHOT_NAME: ${{ inputs.aws_aurora_snapshot_name }}
515+
AWS_AURORA_SNAPSHOT_OVERWRITE: ${{ inputs.aws_aurora_snapshot_overwrite }}
516+
AWS_AURORA_DATABASE_PROTECTION: ${{ inputs.aws_aurora_database_protection }}
517+
AWS_AURORA_DATABASE_FINAL_SNAPSHOT: ${{ inputs.aws_aurora_database_final_snapshot }}
518518

519519
# Docker
520520
DOCKER_INSTALL: ${{ inputs.docker_install }}

operations/_scripts/deploy/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ cat $GITHUB_ACTION_PATH/operations/deployment/bitops.config.yaml
7676

7777
## Ensuring bucket get's destroyed only if everything is set to be destroyed
7878
if [[ $(alpha_only "$TF_STATE_BUCKET_DESTROY") == true ]] && ! [[ $(alpha_only "$TF_STACK_DESTROY") == true ]] ; then
79-
if [[ $(alpha_only "$AWS_POSTGRES_ENABLE") == true ]] ||
79+
if [[ $(alpha_only "$AWS_AURORA_ENABLE") == true ]] ||
8080
[[ $(alpha_only "$AWS_EFS_ENABLE") == true ]] ||
8181
[[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") == true ]] ||
8282
[[ $(alpha_only "$AWS_EKS_CREATE") == true ]]; then

operations/_scripts/generate/generate_bitops_config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bitops:
120120
create_bitops_terraform_config aws false targets
121121
fi
122122
else
123-
if [[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") == true ]] || [[ $(alpha_only "$AWS_EFS_CREATE") == true ]] || [[ "$AWS_POSTGRES_ENABLE" != "" ]]; then
123+
if [[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") == true ]] || [[ $(alpha_only "$AWS_EFS_CREATE") == true ]] || [[ "$AWS_AURORA_ENABLE" != "" ]]; then
124124
add_terraform_module aws
125125
create_bitops_terraform_config aws true targets
126126
fi

0 commit comments

Comments
 (0)