Skip to content

Commit

Permalink
Utilise tags for retrieving Aurora VPC
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanemerson committed Jul 20, 2023
1 parent 59bdf09 commit 936c55c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
1 change: 1 addition & 0 deletions provision/aws/rds/aurora_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fi
# Create the Aurora VPC
AURORA_VPC=$(aws ec2 create-vpc \
--cidr-block ${AURORA_VPC_CIDR} \
--tag-specifications "ResourceType=vpc, Tags=[{Key=AuroraCluster,Value=${AURORA_CLUSTER}}]" \
--output json \
| jq -r '.Vpc.VpcId'
)
Expand Down
11 changes: 1 addition & 10 deletions provision/aws/rds/aurora_create_peering_connection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,12 @@ sh ${SCRIPT_DIR}/../rosa_oc_login.sh
export AWS_REGION=$(rosa describe cluster -c ${CLUSTER_NAME} -o json | jq -r .region.id)

AURORA_VPC=$(aws ec2 describe-vpcs \
--filters "Name=cidr,Values=${AURORA_VPC_CIDR}" \
--filters "Name=cidr,Values=${AURORA_VPC_CIDR}" "Name=tag:AuroraCluster,Values=${AURORA_CLUSTER}" \
--query 'Vpcs[*].VpcId' \
--region ${AURORA_REGION} \
--output text
)

if [ -z "${AURORA_VPC}" ]; then
AURORA_VPC=$(aws ec2 create-vpc \
--cidr-block ${AURORA_VPC_CIDR} \
--region ${AURORA_REGION} \
--output json \
| jq -r '.Vpc.VpcId'
)
fi

NODE=$(oc get nodes --selector=node-role.kubernetes.io/worker \
-o jsonpath='{.items[0].metadata.name}'
)
Expand Down
2 changes: 1 addition & 1 deletion provision/aws/rds/aurora_delete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/aurora_common.sh

AURORA_VPC=$(aws ec2 describe-vpcs \
--filters "Name=cidr-block,Values=${AURORA_VPC_CIDR}" \
--filters "Name=cidr-block,Values=${AURORA_VPC_CIDR}" "Name=tag:AuroraCluster,Values=${AURORA_CLUSTER}" \
--query "Vpcs[*].VpcId" \
--output text
)
Expand Down
2 changes: 1 addition & 1 deletion provision/aws/rds/aurora_delete_peering_connection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fi
# Delete the Aurora VPC Security Group
if [ -n ${AURORA_REGION} ]; then
AURORA_VPC=$(aws ec2 describe-vpcs \
--filters "Name=cidr,Values=${AURORA_VPC_CIDR}" \
--filters "Name=cidr,Values=${AURORA_VPC_CIDR}" "Name=tag:AuroraCluster,Values=${AURORA_CLUSTER}" \
--query 'Vpcs[*].VpcId' \
--region ${AURORA_REGION} \
--output text
Expand Down

0 comments on commit 936c55c

Please sign in to comment.