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 8623b39 commit 4947d05
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions aws/aws_eks_create_custom_ami.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,34 @@ if ! is_blank "$instance_profile"; then
--instance-id "$instance_id" \
--iam-instance-profile Name="$instance_profile"
echo >&2
timestamp "Waiting for profile to fully attach..."

instance_profile_attached=0

for((i=1; i <= 100 ; i++)); do
actual_instance_profile="$(
aws ec2 describe-instances \
--instance-ids "$instance_id" \
--query "Reservations[0].Instances[0].IamInstanceProfile.Arn" \
--output text
)"

if [ "$actual_instance_profile" = "None" ]; then
timestamp "No instance profile associated yet..."
elif [ "$actual_instance_profile" = "$instance_profile" ]; then
timestamp "Instance profile attached"
instance_profile_attached=1
break
else
timestamp "Waiting for instance profile to attach..."
fi

sleep 3
done
fi

if [ "$instance_profile_attached" != 1 ]; then
die "Instance profile failed to attach, gave up waiting"
fi

"$srcdir/aws_ec2_wait_for_instance_ready.sh" "$instance_id"
Expand Down

0 comments on commit 4947d05

Please sign in to comment.