Skip to content

Commit

Permalink
updated aws_eks_create_custom_ami.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
HariSekhon committed Jan 31, 2025
1 parent e342bfb commit 0773a7e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions aws/aws_eks_create_custom_ami.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,18 @@ for((i=1; i <= 100 ; i++)); do
--output text
)"

timestamp "Checking the instance state isn't terminated"
instance_state="$(
aws ec2 describe-instances \
--instance-ids "$instance_id" \
--query "Reservations[0].Instances[0].State.Name" \
--output text
)"
if [ "$instance_id" != "None" ] &&
[ "$instance_state" = "terminated" ]; then
timestamp "This instance is already terminated, will try a new instance name"
continue
if [ "$instance_id" != "None" ]; then
timestamp "Checking the instance state isn't terminated"
instance_state="$(
aws ec2 describe-instances \
--instance-ids "$instance_id" \
--query "Reservations[0].Instances[0].State.Name" \
--output text
)"
if [ "$instance_state" = "terminated" ]; then
timestamp "This instance is already terminated, will try a new instance name"
continue
fi
fi

if is_blank "$instance_id" || [ "$instance_id" = "None" ]; then
Expand Down

0 comments on commit 0773a7e

Please sign in to comment.