v = boto.vpc.VPCConnection(region=eu-west-1) ==> NameError: name 'eu' is not defined

675 views
Skip to first unread message

JPalmer

unread,
Mar 5, 2014, 6:26:32 AM3/5/14
to boto-...@googlegroups.com
Hi All,

Apologies for the "potentially stupid" question.
But this issue is unfortunately bugging me.

Traceback (most recent call last):
  File "./xxxxxx.py", line 165, in <module>
    v = boto.vpc.VPCConnection(region=
eu-west-1)
NameError: name 'eu' is not defined

How do I pass the region name contains hyphens (a.k.a. dashes) into boto.vpc.VPCConnection?

Best Regards
JPalmer

Mitchell Garnaat

unread,
Mar 5, 2014, 7:27:15 AM3/5/14
to boto-users
The region parameter wants a RegionInfo object.  But, really, the easiest way to get a connection for a specific region is to do this:

>>> import boto.vpc
>>> v = boto.vpc.connect_to_region("eu-west-1")

This basic approach works across all services in boto.

Mitch


--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boto-users+...@googlegroups.com.
To post to this group, send email to boto-...@googlegroups.com.
Visit this group at http://groups.google.com/group/boto-users.
For more options, visit https://groups.google.com/groups/opt_out.

JPalmer

unread,
Mar 5, 2014, 9:25:02 AM3/5/14
to boto-...@googlegroups.com, mi...@garnaat.com
Hi Mitch,

Thank you for the prompt answer. I am truly appreciated it.
I have eventually realised that as well which it is a RegionInfo object.
I've pasted below my worked combinations for newbies like me to use as a template.

Best Regards: JPalmer

#------------------------------
        myregion = boto.ec2.get_region(region_name='eu-west-1')
        v = boto.connect_vpc(region=myregion)
#------------------------------
        myregion = boto.ec2.get_region(region_name='eu-west-1')
        v = boto.vpc.VPCConnection(region=myregion)
#------------------------------
        v = boto.vpc.VPCConnection(region=regions[3])
#------------------------------

        v = boto.vpc.connect_to_region('eu-west-1')
#------------------------------
        v = boto.vpc.connect_to_region(AWS_DEFAULT_REGION)
#------------------------------
Reply all
Reply to author
Forward
0 new messages