-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shell script to start redis-cluster
- Loading branch information
Siddharth More
authored and
Siddharth More
committed
Nov 28, 2023
1 parent
54e1c83
commit 760ed68
Showing
2 changed files
with
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
REDIS_CLUSTER_ID="test-eigenda-redis-cluster" | ||
REDIS_PORT="6379" | ||
AWS_REGION="us-east-1" | ||
|
||
# Check if the Redis cluster already exists | ||
function redis_cluster_exists() { | ||
aws elasticache describe-cache-clusters --region $AWS_REGION | grep -q $REDIS_CLUSTER_ID | ||
return $? | ||
} | ||
|
||
# Start Redis service using LocalStack | ||
function create_redis_cluster() { | ||
aws elasticache create-cache-cluster \ | ||
--cache-cluster-id $REDIS_CLUSTER_ID \ | ||
--engine redis \ | ||
--cache-node-type cache.t2.micro \ | ||
--num-cache-nodes 1 \ | ||
--port $REDIS_PORT \ | ||
--region $AWS_REGION | ||
} | ||
|
||
# Check if Redis cluster exists and create it if it does not | ||
if redis_cluster_exists; then | ||
echo "Redis cluster $REDIS_CLUSTER_ID already exists." | ||
else | ||
echo "Creating Redis cluster $REDIS_CLUSTER_ID." | ||
create_redis_cluster | ||
fi |
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