Skip to content

Commit

Permalink
Rename ec2_url
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Sep 6, 2022
1 parent 08746a1 commit 76bba8c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/992-ec2_url.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- amazon.aws modules - the ``ec2_url`` parameter has been renamed to ``endpoint_url`` for consistency, ``ec2_url`` remains as an alias (https://github.com/ansible-collections/amazon.aws/pull/992).
4 changes: 2 additions & 2 deletions plugins/doc_fragments/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class ModuleDocFragment(object):
a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used.
type: bool
default: 'no'
ec2_url:
endpoint_url:
description:
- URL to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints).
Ignored for modules where region is required. Must be specified for all other modules if region is not used.
If not set then the value of the EC2_URL environment variable, if any, is used.
type: str
aliases: [ aws_endpoint_url, endpoint_url ]
aliases: [ ec2_url, aws_endpoint_url ]
aws_secret_key:
description:
- C(AWS secret key). If not set then the value of the C(AWS_SECRET_ACCESS_KEY), C(AWS_SECRET_KEY), or C(EC2_SECRET_KEY) environment variable is used.
Expand Down
10 changes: 5 additions & 5 deletions plugins/module_utils/botocore.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def get_aws_connection_info(module, boto3=None):
# Check module args for credentials, then check environment vars
# access_key

ec2_url = module.params.get('ec2_url')
endpoint_url = module.params.get('endpoint_url')
access_key = module.params.get('aws_access_key')
secret_key = module.params.get('aws_secret_key')
security_token = module.params.get('security_token')
Expand All @@ -185,11 +185,11 @@ def get_aws_connection_info(module, boto3=None):
if profile_name and (access_key or secret_key or security_token):
module.fail("Passing both a profile and access tokens is not supported.")

if not ec2_url:
if not endpoint_url:
if 'AWS_URL' in os.environ:
ec2_url = os.environ['AWS_URL']
endpoint_url = os.environ['AWS_URL']
elif 'EC2_URL' in os.environ:
ec2_url = os.environ['EC2_URL']
endpoint_url = os.environ['EC2_URL']

if not access_key:
if os.environ.get('AWS_ACCESS_KEY_ID'):
Expand Down Expand Up @@ -248,7 +248,7 @@ def get_aws_connection_info(module, boto3=None):
if isinstance(value, binary_type):
boto_params[param] = text_type(value, 'utf-8', 'strict')

return region, ec2_url, boto_params
return region, endpoint_url, boto_params


def _paginated_query(client, paginator_name, **params):
Expand Down
10 changes: 5 additions & 5 deletions plugins/module_utils/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ def md5(self, *args, **kwargs):
return self._module.md5(*args, **kwargs)

def client(self, service, retry_decorator=None):
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(self, boto3=True)
region, endpoint_url, aws_connect_kwargs = get_aws_connection_info(self, boto3=True)
conn = boto3_conn(self, conn_type='client', resource=service,
region=region, endpoint=ec2_url, **aws_connect_kwargs)
region=region, endpoint=endpoint_url, **aws_connect_kwargs)
return conn if retry_decorator is None else _RetryingBotoClientWrapper(conn, retry_decorator)

def resource(self, service):
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(self, boto3=True)
region, endpoint_url, aws_connect_kwargs = get_aws_connection_info(self, boto3=True)
return boto3_conn(self, conn_type='resource', resource=service,
region=region, endpoint=ec2_url, **aws_connect_kwargs)
region=region, endpoint=endpoint_url, **aws_connect_kwargs)

@property
def region(self):
Expand Down Expand Up @@ -349,7 +349,7 @@ def _aws_common_argument_spec():
"""
return dict(
debug_botocore_endpoint_logs=dict(fallback=(env_fallback, ['ANSIBLE_DEBUG_BOTOCORE_LOGS']), default=False, type='bool'),
ec2_url=dict(aliases=['aws_endpoint_url', 'endpoint_url']),
endpoint_url=dict(aliases=['ec2_url', 'aws_endpoint_url']),
aws_access_key=dict(aliases=['ec2_access_key', 'access_key'], no_log=False),
aws_secret_key=dict(aliases=['ec2_secret_key', 'secret_key'], no_log=True),
security_token=dict(aliases=['access_token', 'aws_security_token', 'session_token', 'aws_session_token'], no_log=True),
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/targets/module_utils_core/aliases
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
cloud/aws

module_utils_botocore
module_utils_modules

0 comments on commit 76bba8c

Please sign in to comment.