Reputation: 2571
I'm creating a VPC and security groups with boto. If I just create and tag elements in a script I keep getting errors, because the elements aren't ready yet. I can just put in a manual wait, but I prefer to pull them to see if they are actually ready. For the VPCs or subnets I can use something like:
import boto.vpc
v = boto.vpc.VPCConnection(
region=primary_region,
aws_access_key_id=aws_access_key,
aws_secret_access_key=aws_secret_key)
vpcs = v.get_all_vpcs()
print vpcs[0].state
with some more logic and a while loop to check if the state is available
, running
or whatever. This works fine for most vpc / aws elements, but some elements like security groups don't have a state attribute when returned with get_all_security_groups
or there equivalent.
How do people check if these elements are ready to be used?
Upvotes: 5
Views: 690
Reputation: 8061
Turns out that for the elements without a state property, you have to get creative and write some potentially brittle code.
For the specific example of security groups, I do:
When it starts to fail (and I'm sure it will), I'll take another look at other and better ways, but has worked without fail so far.
Upvotes: 1