-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroboshop.sh
More file actions
41 lines (37 loc) · 1.61 KB
/
roboshop.sh
File metadata and controls
41 lines (37 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
AMI_ID="ami-0220d79f3f480ecf5"
SG_ID="sg-07371893307e5de2e" # replace with your SG ID
INSTANCES=("mongodb" "redis" "mysql" "rabbitmq" "catalogue" "user" "cart" "shipping" "payment" "dispatch" "frontend")
ZONE_ID="Z06106853F57AZAYTFTYS" # replace with your ZONE ID
DOMAIN_NAME="aryavirtuoso.site" # replace with your domain
#for instance in ${INSTANCES[@]}
for instance in $@
do
INSTANCE_ID=$(aws ec2 run-instances --image-id ami-0220d79f3f480ecf5 --instance-type t3.micro --security-group-ids sg-07371893307e5de2e --tag-specifications "ResourceType=instance,Tags=[{Key=Name, Value=$instance}]" --query "Instances[0].InstanceId" --output text)
if [ $instance != "frontend" ]
then
IP=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query "Reservations[0].Instances[0].PrivateIpAddress" --output text)
RECORD_NAME="$instance.$DOMAIN_NAME"
else
IP=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query "Reservations[0].Instances[0].PublicIpAddress" --output text)
RECORD_NAME="$DOMAIN_NAME"
fi
echo "$instance IP address: $IP"
aws route53 change-resource-record-sets \
--hosted-zone-id $ZONE_ID \
--change-batch '
{
"Comment": "Creating or Updating a record set for cognito endpoint"
,"Changes": [{
"Action" : "UPSERT"
,"ResourceRecordSet" : {
"Name" : "'$RECORD_NAME'"
,"Type" : "A"
,"TTL" : 1
,"ResourceRecords" : [{
"Value" : "'$IP'"
}]
}
}]
}'
done