Skip to content

Commit dee4060

Browse files
authored
Cosmetic fixes (#109)
* Appending aws_ to postgres variables * Simplifying sed command for outputs (Thanks ChatGPT) * Making GHA result more resilient * Migrating translations * Added function definition, updated name * Removing RDS defaults
1 parent 8fda8d1 commit dee4060

File tree

11 files changed

+168
-276
lines changed

11 files changed

+168
-276
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ The following inputs can be used as `step.with` keys
184184
#### **RDS Inputs**
185185
| Name | Type | Description |
186186
|------------------|---------|------------------------------------|
187-
| `enable_postgres` | Boolean | Set to "true" to enable a postgres database. |
188-
| `postgres_engine` | String | Which Database engine to use. Default is `aurora-postgresql`.|
189-
| `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.13`. |
190-
| `postgres_instance_class` | String | Define the size of the instances in the DB cluster. Default is `db.t3.medium`. |
191-
| `postgres_subnets` | String | Specify which subnets to use as a list of strings. Example: `i-1234,i-5678,i-9101`. |
192-
| `postgres_database_name` | String | Specify a database name. Will be created if it does not exist. Default is `root`. |
193-
| `postgres_database_port` | String | Specify a listening port for the database. Default is `5432`.|
187+
| `aws_enable_postgres` | Boolean | Set to "true" to enable a postgres database. |
188+
| `aws_postgres_engine` | String | Which Database engine to use. Default is `aurora-postgresql`.|
189+
| `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.13`. |
190+
| `aws_postgres_instance_class` | String | Define the size of the instances in the DB cluster. Default is `db.t3.medium`. |
191+
| `aws_postgres_subnets` | String | Specify which subnets to use as a list of strings. Example: `i-1234,i-5678,i-9101`. |
192+
| `aws_postgres_database_name` | String | Specify a database name. Will be created if it does not exist. Default is `root`. |
193+
| `aws_postgres_database_port` | String | Specify a listening port for the database. Default is `5432`.|
194194
<hr/>
195195
<br/>
196196

@@ -289,7 +289,7 @@ An example EFS Zone mapping;
289289

290290
## Adding external Postgres database (AWS RDS)
291291

292-
If `enable_postgres` is set to `true`, this action will deploy an RDS cluster for Postgres.
292+
If `aws_enable_postgres` is set to `true`, this action will deploy an RDS cluster for Postgres.
293293

294294
### Environment variables
295295
The following environment variables are added to the `.env` file in your app's `docker-compose.yaml` file.
@@ -353,7 +353,7 @@ Specifically, the following resources will be created:
353353
- AWS Security Group
354354
- AWS Security Group Rule - Allows access to the cluster's db port: `5432`
355355
- AWS RDS Aurora Postgres
356-
- Includes a single database (set by the input: `postgres_database_name`. defaults to `root`)
356+
- Includes a single database (set by the input: `aws_postgres_database_name`. defaults to `root`)
357357

358358
Additional details about the cluster that's created:
359359
- Automated backups (7 Days)

action.yaml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,34 +133,28 @@ inputs:
133133
default: false
134134

135135
# RDS
136-
enable_postgres:
136+
aws_enable_postgres:
137137
description: Set to "true" to enable a postgres database
138138
required: false
139-
postgres_engine:
139+
aws_postgres_engine:
140140
description: Which Database engine to use
141141
required: false
142-
default: 'aurora-postgresql'
143-
postgres_engine_version:
142+
aws_postgres_engine_version:
144143
description: Specify Postgres version
145144
required: false
146-
default: '11.13'
147-
postgres_instance_class:
145+
aws_postgres_instance_class:
148146
description: Define the size of the instances in the DB cluster
149147
required: false
150-
default: 'db.t3.medium'
151-
postgres_subnets:
148+
aws_postgres_subnets:
152149
description: 'Specify which subnets to use as a list of strings. Example: `i-1234,i-5678,i-9101`'
153150
required: false
154-
default: ''
155-
postgres_database_name:
151+
aws_postgres_database_name:
156152
description: 'Specify a database name. Will be created if it does not exist'
157153
required: false
158154
# TODO: create another user and point to that instead
159-
default: 'root'
160-
postgres_database_port:
155+
aws_postgres_database_port:
161156
description: 'Postgres database port'
162157
required: false
163-
default: '5432'
164158

165159
# Ansible
166160
application_mount_target:
@@ -219,13 +213,13 @@ runs:
219213
APP_DIRECTORY: ${{ inputs.app_directory }}
220214
CREATE_KEYPAIR_SM_ENTRY: ${{ inputs.create_keypair_sm_entry }}
221215
ADDITIONAL_TAGS: ${{ inputs.additional_tags }}
222-
ENABLE_POSTGRES: ${{ inputs.enable_postgres }}
223-
POSTGRES_ENGINE: ${{ inputs.postgres_engine }}
224-
POSTGRES_ENGINE_VERSION: ${{ inputs.postgres_engine_version }}
225-
POSTGRES_INSTANCE_CLASS: ${{ inputs.postgres_instance_class }}
226-
POSTGRES_SUBNETS: ${{ inputs.postgres_subnets }}
227-
POSTGRES_DATABASE_NAME: ${{ inputs.postgres_database_name }}
228-
POSTGRES_DATABASE_PORT: ${{ inputs.postgres_database_port}}
216+
AWS_ENABLE_POSTGRES: ${{ inputs.aws_enable_postgres }}
217+
AWS_POSTGRES_ENGINE: ${{ inputs.aws_postgres_engine }}
218+
AWS_POSTGRES_ENGINE_VERSION: ${{ inputs.aws_postgres_engine_version }}
219+
AWS_POSTGRES_INSTANCE_CLASS: ${{ inputs.aws_postgres_instance_class }}
220+
AWS_POSTGRES_SUBNETS: ${{ inputs.aws_postgres_subnets }}
221+
AWS_POSTGRES_DATABASE_NAME: ${{ inputs.aws_postgres_database_name }}
222+
AWS_POSTGRES_DATABASE_PORT: ${{ inputs.aws_postgres_database_port}}
229223
AWS_CREATE_EFS: ${{ inputs.aws_create_efs }}
230224
AWS_CREATE_HA_EFS: ${{ inputs.aws_create_ha_efs }}
231225
AWS_CREATE_EFS_REPLICA: ${{ inputs.aws_create_efs_replica }}
@@ -252,18 +246,25 @@ runs:
252246
run: |
253247
echo "## VM Created! :rocket:" >> $GITHUB_STEP_SUMMARY
254248
echo " ${{ steps.deploy.outputs.vm_url }}" >> $GITHUB_STEP_SUMMARY
255-
- if: ${{ success() && steps.deploy.outputs.vm_url == '' && inputs.tf_state_bucket_destroy == 'false' }}
249+
- if: ${{ success() && steps.deploy.outputs.vm_url == '' && inputs.stack_destroy == 'true' && inputs.tf_state_bucket_destroy == 'false' }}
256250
name: Print result destroyed
257251
shell: bash
258252
run: |
259253
echo "## VM Destroyed! :boom:" >> $GITHUB_STEP_SUMMARY
260254
echo "Infrastructure should be gone now!" >> $GITHUB_STEP_SUMMARY
261-
- if: ${{ success() && steps.deploy.outputs.vm_url == '' && inputs.tf_state_bucket_destroy == 'true' }}
255+
- if: ${{ success() && steps.deploy.outputs.vm_url == '' && inputs.stack_destroy == 'true' && inputs.tf_state_bucket_destroy == 'true' }}
262256
name: Print result destroyed
263257
shell: bash
264258
run: |
265259
echo "## VM Destroyed! :boom:" >> $GITHUB_STEP_SUMMARY
266260
echo "Buckets and infrastructure should be gone now!" >> $GITHUB_STEP_SUMMARY
261+
- if: ${{ success() && steps.deploy.outputs.vm_url == '' && inputs.stack_destroy == 'false' }}
262+
name: Print result destroyed
263+
shell: bash
264+
run: |
265+
echo "## Deploy finished! But no URL found. :thinking: " >> $GITHUB_STEP_SUMMARY
266+
echo "If expecting an URL, please check the logs for possible errors." >> $GITHUB_STEP_SUMMARY
267+
echo "If you consider this is a bug in the Github Action, please submit an issue to our repo." >> $GITHUB_STEP_SUMMARY
267268
- if: ${{ failure() }}
268269
name: Print error result
269270
shell: bash

operations/_scripts/deploy/deploy.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ export LB_LOGS_BUCKET="$(/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/gener
2828

2929
# Generate bitops config
3030
/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/generate/generate_bitops_config.sh
31+
32+
# List terraform folder
33+
echo "ls -al $GITHUB_ACTION_PATH/operations/deployment/terraform/"
3134
ls -al $GITHUB_ACTION_PATH/operations/deployment/terraform/
35+
# Prints out bitops.config.yaml
36+
echo "cat $GITHUB_ACTION_PATH/operations/deployment/terraform/bitops.config.yaml"
3237
cat $GITHUB_ACTION_PATH/operations/deployment/terraform/bitops.config.yaml
3338

3439

3540
echo "cat GITHUB_ACTION_PATH/operations/deployment/terraform/provider.tf"
3641
cat $GITHUB_ACTION_PATH/operations/deployment/terraform/provider.tf
37-
echo "cat GITHUB_ACTION_PATH/operations/deployment/terraform/terraform.tfvars"
3842
echo "ls GITHUB_ACTION_PATH/operations/deployment/ansible/app/${GITHUB_REPO_NAME}"
3943
ls "$GITHUB_ACTION_PATH/operations/deployment/ansible/app/${GITHUB_REPO_NAME}"
4044

operations/_scripts/generate/generate_buckets_identifiers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
GITHUB_IDENTIFIER="$(echo $($GITHUB_ACTION_PATH/operations/_scripts/generate/generate_identifier.sh) | tr '[:upper:]' '[:lower:]' | tr '_' '-' | tr '/' '-' )"
5+
GITHUB_IDENTIFIER="$($GITHUB_ACTION_PATH/operations/_scripts/generate/generate_identifier.sh)"
66

77
case $1 in
88
tf)

operations/_scripts/generate/generate_identifier.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ if [ -z "$AWS_RESOURCE_IDENTIFIER" ]; then
1717
else
1818
GITHUB_IDENTIFIER="$AWS_RESOURCE_IDENTIFIER"
1919
fi
20-
# todo: echo "$GITHUB_IDENTIFIER" | xargs | tr '[:upper:]' '[:lower:]' | tr '_' '-' | tr '/' '-'
20+
21+
GITHUB_IDENTIFIER=$(echo $GITHUB_IDENTIFIER | tr '[:upper:]' '[:lower:]' | tr '_' '-' | tr '/' '-')
22+
2123
echo "$GITHUB_IDENTIFIER" | xargs

operations/_scripts/generate/generate_identifier_supershort.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
if [ -z "$AWS_RESOURCE_IDENTIFIER" ]; then
6-
GITHUB_IDENTIFIER="$(echo $($GITHUB_ACTION_PATH/operations/_scripts/generate/generate_identifier.sh) | tr '/' '-' )"
6+
GITHUB_IDENTIFIER="$($GITHUB_ACTION_PATH/operations/_scripts/generate/generate_identifier.sh)"
77
GITHUB_IDENTIFIER="$($GITHUB_ACTION_PATH/operations/_scripts/generate/shorten_identifier.sh ${GITHUB_IDENTIFIER} 30)"
88
else
99
GITHUB_IDENTIFIER="$AWS_RESOURCE_IDENTIFIER"

0 commit comments

Comments
 (0)