lb2
This commit is contained in:
parent
14161fd8ef
commit
7e35161c5b
17
lb2.py
17
lb2.py
@ -2,6 +2,7 @@ import boto3
|
||||
import base64
|
||||
from USER_DATA import user_data
|
||||
import json
|
||||
import time
|
||||
|
||||
# Configuration variables
|
||||
PREFIX = "s464863"
|
||||
@ -246,6 +247,22 @@ def create_ec2_instances(ec2_client, launch_template_id, subnet_id):
|
||||
return instance_ids
|
||||
|
||||
|
||||
def wait_for_instances_to_run(ec2_client, instance_ids):
|
||||
print("Waiting for EC2 instances to be in 'running' state...")
|
||||
|
||||
while True:
|
||||
# Get state of instances
|
||||
response = ec2_client.describe_instances(InstanceIds=instance_ids)
|
||||
states = [reservation['Instances'][0]['State']['Name'] for reservation in response['Reservations']]
|
||||
|
||||
# Check if all instances are running
|
||||
if all(state == 'running' for state in states):
|
||||
print("All EC2 instances are now 'running'.")
|
||||
break
|
||||
else:
|
||||
print("Waiting for EC2 instances to reach 'running' state...")
|
||||
time.sleep(10)
|
||||
|
||||
# Main function
|
||||
def main():
|
||||
# EC2 client
|
||||
|
Loading…
Reference in New Issue
Block a user