Skip to content

Commit

Permalink
Add instance type and engine version parameters to GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanemerson committed Jul 21, 2023
1 parent 255a9d8 commit e2d174a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/actions/aurora-create-database/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
region:
description: 'The AWS region used to host the Aurora DB'
required: true
engineVersion:
description: 'The Postgres engine version to use'
instanceClass:
description: 'Instance class for the Aurora DB'

runs:
using: "composite"
Expand All @@ -18,4 +22,6 @@ runs:
working-directory: provision/aws/rds
env:
AURORA_CLUSTER: ${{ inputs.name }}
AURORA_ENGINE_VERSION: ${{ inputs.engineVersion }}
AURORA_INSTANCE_CLASS: ${{ inputs.instanceClass }}
AWS_REGION: ${{ inputs.region }}
8 changes: 8 additions & 0 deletions .github/workflows/aurora-create-database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ on:
description: 'The AWS region used to host the Aurora DB'
type: string
required: true
engineVersion:
description: 'The Postgres engine version to use'
type: string
instanceClass:
description: 'Instance class for the Aurora DB'
type: string

jobs:
prepare:
Expand All @@ -33,3 +39,5 @@ jobs:
with:
name: ${{ inputs.name }}
region: ${{ inputs.region }}
engineVersion: ${{ inputs.engineVersion }}
instanceClass: ${{ inputs.instanceClass }}
12 changes: 8 additions & 4 deletions provision/aws/rds/aurora_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ if [ -f ./.env ]; then
fi

export AURORA_CLUSTER=${AURORA_CLUSTER:-"keycloak"}
export AURORA_INSTANCE=${AURORA_INSTANCE:-"${AURORA_CLUSTER}-instance-1"}
export AURORA_ENGINE=${AURORA_ENGINE:-"aurora-postgresql"}
export AURORA_USERNAME=${AURORA_USERNAME:-"keycloak"}
export AURORA_ENGINE_VERSION=${AURORA_ENGINE_VERSION:-"15.3"}
export AURORA_INSTANCE=${AURORA_INSTANCE:-"${AURORA_CLUSTER}-instance-1"}
export AURORA_INSTANCE_CLASS=${AURORA_INSTANCE_CLASS:-"db.t4g.large"}
export AURORA_PASSWORD=${AURORA_PASSWORD:-"secret99"}
export AURORA_SUBNET_GROUP_NAME=${AURORA_SUBNET_GROUP_NAME:-"${AURORA_CLUSTER}-subnet-group"}
export AURORA_REGION=${AURORA_REGION}
export AURORA_SECURITY_GROUP_NAME=${AURORA_SECURITY_GROUP_NAME:-"${AURORA_CLUSTER}-security-group"}
export AURORA_SUBNET_A_CIDR=${AURORA_SUBNET_A_CIDR:-"192.168.0.0/19"}
export AURORA_SUBNET_B_CIDR=${AURORA_SUBNET_B_CIDR:-"192.168.32.0/19"}
export AURORA_SUBNET_GROUP_NAME=${AURORA_SUBNET_GROUP_NAME:-"${AURORA_CLUSTER}-subnet-group"}
export AURORA_USERNAME=${AURORA_USERNAME:-"keycloak"}
export AURORA_VPC_CIDR=${AURORA_VPC_CIDR:-"192.168.0.0/16"}
export AURORA_REGION=${AURORA_REGION}
export AWS_REGION=${AWS_REGION:-${AURORA_REGION}}
export AWS_PAGER=""
7 changes: 4 additions & 3 deletions provision/aws/rds/aurora_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ AURORA_VPC=$(aws ec2 create-vpc \
SUBNET_A=$(aws ec2 create-subnet \
--availability-zone "${AWS_REGION}a" \
--vpc-id ${AURORA_VPC} \
--cidr-block 192.168.0.0/19 \
--cidr-block ${AURORA_SUBNET_A_CIDR} \
--output json \
| jq -r '.Subnet.SubnetId'
)

SUBNET_B=$(aws ec2 create-subnet \
--availability-zone "${AWS_REGION}b" \
--vpc-id ${AURORA_VPC} \
--cidr-block 192.168.32.0/19 \
--cidr-block ${AURORA_SUBNET_B_CIDR} \
--output json \
| jq -r '.Subnet.SubnetId'
)
Expand Down Expand Up @@ -78,6 +78,7 @@ aws rds create-db-cluster \
--db-cluster-identifier ${AURORA_CLUSTER} \
--database-name keycloak \
--engine ${AURORA_ENGINE} \
--engine-version ${AURORA_ENGINE_VERSION} \
--master-username ${AURORA_USERNAME} \
--master-user-password ${AURORA_PASSWORD} \
--vpc-security-group-ids ${AURORA_SECURITY_GROUP_ID} \
Expand All @@ -86,7 +87,7 @@ aws rds create-db-cluster \
aws rds create-db-instance \
--db-cluster-identifier ${AURORA_CLUSTER} \
--db-instance-identifier ${AURORA_INSTANCE} \
--db-instance-class db.t4g.large \
--db-instance-class ${AURORA_INSTANCE_CLASS} \
--engine ${AURORA_ENGINE}

aws rds wait db-instance-available --db-instance-identifier ${AURORA_INSTANCE}

0 comments on commit e2d174a

Please sign in to comment.