-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create runners and organize dirs (#8)
- Loading branch information
1 parent
d34b393
commit 309bc1a
Showing
23 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
. ./bin/aws/utils | ||
|
||
check_aws_cli_installed | ||
check_helm_installed | ||
|
||
# Function to clean up resources in case of failure | ||
cleanup() { | ||
echo "[UTILS] [EKS] An error occurred." | ||
} | ||
|
||
# Trap any error, and call our cleanup function | ||
trap cleanup ERR | ||
|
||
# Source .env file | ||
. .env | ||
|
||
# 1. Create cluster | ||
./bin/aws/eks/cluster/create | ||
|
||
# 2. Setup secrets | ||
./bin/aws/eks/setup-secrets | ||
|
||
# 3. Apply deployments | ||
# kubectl apply -f deployment/secrets.yml | ||
# kubectl apply -f deployment/sidekiq.yml | ||
# kubectl apply -f deployment/app.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
. ./bin/aws/utils | ||
|
||
check_aws_cli_installed | ||
|
||
# Function to clean up resources in case of failure | ||
cleanup() { | ||
echo "[UTILS] [RDS] An error occurred. Deleting RDS instance..." | ||
./bin/aws/rds/instance/delete | ||
} | ||
|
||
# Trap any error, and call our cleanup function | ||
trap cleanup ERR | ||
|
||
# Source .env file | ||
. .env | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Create RDS instance | ||
# ---------------------------------------------------------------------------- | ||
|
||
echo "[UTILS] [RDS] Running RDS creation script for $DB_INSTANCE_ID..." | ||
|
||
./bin/aws/rds/instance/create | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Wait for RDS instance to be available | ||
# ---------------------------------------------------------------------------- | ||
|
||
DB_STATUS="" | ||
|
||
while [ "$DB_STATUS" != "available" ]; do | ||
echo "[UTILS] [RDS] Waiting for RDS instance to be available..." | ||
|
||
DB_STATUS=$(bin/aws/rds/instance/status) | ||
|
||
sleep 10 | ||
done | ||
|
||
echo "[UTILS] [RDS] The RDS instance is available." | ||
|
||
DB_ARN=$(./bin/aws/rds/instance/describe) | ||
|
||
echo "[UTILS] [RDS] The ARN of the RDS instance is: $DB_ARN" | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Update .env file with RDS instance ARN | ||
# ---------------------------------------------------------------------------- | ||
|
||
ENV_FILE=".env" | ||
KEY_TO_REPLACE="DB_ARN" | ||
|
||
# Check if key exists in .env file | ||
if grep -q "$KEY_TO_REPLACE" $ENV_FILE; then | ||
# Key found, so update it | ||
echo "[UTILS] [RDS] Updating .env file with RDS instance ARN..." | ||
sed -i '.bak' "s/^$KEY_TO_REPLACE=.*/$KEY_TO_REPLACE=$DB_ARN/" $ENV_FILE | ||
else | ||
# Key not found, so append it | ||
echo "[UTILS] [RDS] Appending .env file with RDS instance ARN..." | ||
echo "$KEY_TO_REPLACE=$DB_ARN" >> $ENV_FILE | ||
fi | ||
|
||
echo "[UTILS] [RDS] Updated .env file with RDS instance ARN: $DB_ARN" | ||
|
||
# Remove the trap since everything was successful | ||
trap - ERR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
. ./bin/aws/utils | ||
|
||
check_aws_cli_installed | ||
|
||
# Function to clean up resources in case of failure | ||
cleanup() { | ||
echo "[UTILS] [REDIS] An error occurred. Deleting RDS instance..." | ||
./bin/aws/ec/redis/replication-group/delete | ||
} | ||
|
||
# Trap any error, and call our cleanup function | ||
trap cleanup ERR | ||
|
||
# Source .env file | ||
. .env | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Create RDS instance | ||
# ---------------------------------------------------------------------------- | ||
|
||
echo "[UTILS] [REDIS] Running Redis creation script for $REPLICATION_GROUP_ID..." | ||
|
||
./bin/aws/ec/redis/replication-group/create | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Wait for Redis instance to be available | ||
# ---------------------------------------------------------------------------- | ||
|
||
REPLICATION_GROUP_STATUS="" | ||
|
||
while [ "$REPLICATION_GROUP_STATUS" != "available" ]; do | ||
echo "[UTILS] [REDIS] Waiting for Redis instance to be available..." | ||
|
||
REPLICATION_GROUP_STATUS=$(./bin/aws/ec/redis/replication-group/status) | ||
|
||
sleep 10 | ||
done | ||
|
||
echo "[UTILS] [REDIS] The Redis instance is available." | ||
|
||
REPLICATION_GROUP_ADDRESS=$(./bin/aws/ec/redis/replication-group/describe) | ||
|
||
echo "[UTILS] [REDIS] The Address of the Redis instance is: $REPLICATION_GROUP_ADDRESS" | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Update .env file with RDS instance ARN | ||
# ---------------------------------------------------------------------------- | ||
|
||
ENV_FILE=".env" | ||
KEY_TO_REPLACE="REPLICATION_GROUP_ADDRESS" | ||
|
||
# Check if key exists in .env file | ||
if grep -q "$KEY_TO_REPLACE" $ENV_FILE; then | ||
# Key found, so update it | ||
echo "[UTILS] [REDIS] Updating .env file with RDS instance ARN..." | ||
sed -i '.bak' "s/^$KEY_TO_REPLACE=.*/$KEY_TO_REPLACE=$REPLICATION_GROUP_ADDRESS/" $ENV_FILE | ||
else | ||
# Key not found, so append it | ||
echo "[UTILS] [REDIS] Appending .env file with RDS instance ARN..." | ||
echo "$KEY_TO_REPLACE=$REPLICATION_GROUP_ADDRESS" >> $ENV_FILE | ||
fi | ||
|
||
echo "[UTILS] [REDIS] Updated .env file with Redis address: $REPLICATION_GROUP_ADDRESS" | ||
|
||
# Remove the trap since everything was successful | ||
trap - ERR |