ec2_vpc_endpoint: make policy_path usable (#31801)

The current code flow precludes the use of the policy_path module
parameter that's documented.  It's actually called policy_file in the
code.

What's worse is that the policy_file branch actually tries to open the
file named by the policy parameter, even though policy and policy_file
are marked as mutually-exclusive.

This change fixes the logic bug in policy_file and updates the
documentation to reference policy_file.  The old parameter policy_path
is provided as an alias
pull/31849/head
Michael Fenn 7 years ago committed by Ryan Brown
parent efec43dd1e
commit eab9ca9a00

@ -39,7 +39,7 @@ options:
- Option when creating an endpoint. If not provided AWS will
utilise a default policy which provides full access to the service.
required: false
policy_path:
policy_file:
description:
- The path to the properly json formatted policy file, see
U(https://github.com/ansible/ansible/issues/7005#issuecomment-42894813)
@ -47,6 +47,7 @@ options:
- Option when creating an endpoint. If not provided AWS will
utilise a default policy which provides full access to the service.
required: false
aliases: [ "policy_path" ]
state:
description:
- present to ensure resource is created.
@ -262,7 +263,7 @@ def create_vpc_endpoint(client, module):
elif module.params.get('policy_file'):
try:
with open(module.params.get('policy'), 'r') as json_data:
with open(module.params.get('policy_file'), 'r') as json_data:
policy = json.load(json_data)
except Exception as e:
module.fail_json(msg=str(e), exception=traceback.format_exc(),
@ -330,7 +331,7 @@ def main():
vpc_id=dict(),
service=dict(),
policy=dict(type='json'),
policy_file=dict(type='path'),
policy_file=dict(type='path', aliases=['policy_path']),
state=dict(default='present', choices=['present', 'absent']),
wait=dict(type='bool', default=False),
wait_timeout=dict(type='int', default=320, required=False),

Loading…
Cancel
Save