Fixed incorrect connect_to_aws call - switched to boto.vpc instead of boto.ec2

This commit is contained in:
whiter 2015-06-29 11:18:04 +10:00
parent 552c4ef53a
commit 155c9ff6c9

View file

@ -20,18 +20,25 @@ short_description: Manage an AWS VPC Internet gateway
description: description:
- Manage an AWS VPC Internet gateway - Manage an AWS VPC Internet gateway
version_added: "2.0" version_added: "2.0"
author: Robert Estelle, @erydo author: Robert Estelle (@erydo)
options: options:
vpc_id: vpc_id:
description: description:
- The VPC ID for the VPC in which to manage the Internet Gateway. - The VPC ID for the VPC in which to manage the Internet Gateway.
required: true required: true
default: null default: null
region:
description:
- The AWS region to use. Must be specified if ec2_url is not used. If not specified then the value of the EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region)
required: false
default: null
aliases: [ 'aws_region', 'ec2_region' ]
state: state:
description: description:
- Create or terminate the IGW - Create or terminate the IGW
required: false required: false
default: present default: present
choices: [ 'present', 'absent' ]
extends_documentation_fragment: aws extends_documentation_fragment: aws
''' '''
@ -39,16 +46,13 @@ EXAMPLES = '''
# Note: These examples do not set authentication details, see the AWS Guide for details. # Note: These examples do not set authentication details, see the AWS Guide for details.
# Ensure that the VPC has an Internet Gateway. # Ensure that the VPC has an Internet Gateway.
# The Internet Gateway ID is can be accessed via {{igw.gateway_id}} for use # The Internet Gateway ID is can be accessed via {{igw.gateway_id}} for use in setting up NATs etc.
# in setting up NATs etc. module: ec2_vpc_igw
local_action: vpc_id: vpc-abcdefgh
module: ec2_vpc_igw state: present
vpc_id: {{vpc.vpc_id}} register: igw
region: {{vpc.vpc.region}}
state: present
register: igw
'''
'''
import sys # noqa import sys # noqa
@ -116,8 +120,8 @@ def main():
argument_spec = ec2_argument_spec() argument_spec = ec2_argument_spec()
argument_spec.update( argument_spec.update(
dict( dict(
vpc_id = dict(required=True), vpc_id = dict(required=True, default=None),
state = dict(choices=['present', 'absent'], default='present') state = dict(required=False, default='present', choices=['present', 'absent'])
) )
) )
@ -133,14 +137,14 @@ def main():
if region: if region:
try: try:
connection = connect_to_aws(boto.ec2, region, **aws_connect_params) connection = connect_to_aws(boto.vpc, region, **aws_connect_params)
except (boto.exception.NoAuthHandlerFound, StandardError), e: except (boto.exception.NoAuthHandlerFound, StandardError), e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
else: else:
module.fail_json(msg="region must be specified") module.fail_json(msg="region must be specified")
vpc_id = module.params.get('vpc_id') vpc_id = module.params.get('vpc_id')
state = module.params.get('state', 'present') state = module.params.get('state')
try: try:
if state == 'present': if state == 'present':