From 76bba8ced0fc81b1ffcf4a4829b0e31147cd77d6 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 5 Sep 2022 09:35:36 +0200 Subject: [PATCH] Rename ec2_url --- changelogs/fragments/992-ec2_url.yml | 2 ++ plugins/doc_fragments/aws.py | 4 ++-- plugins/module_utils/botocore.py | 10 +++++----- plugins/module_utils/modules.py | 10 +++++----- tests/integration/targets/module_utils_core/aliases | 3 +++ 5 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 changelogs/fragments/992-ec2_url.yml diff --git a/changelogs/fragments/992-ec2_url.yml b/changelogs/fragments/992-ec2_url.yml new file mode 100644 index 00000000000..7f5ea7cf5ad --- /dev/null +++ b/changelogs/fragments/992-ec2_url.yml @@ -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). diff --git a/plugins/doc_fragments/aws.py b/plugins/doc_fragments/aws.py index f3ad36e69d0..ae9b5a3cba5 100644 --- a/plugins/doc_fragments/aws.py +++ b/plugins/doc_fragments/aws.py @@ -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. diff --git a/plugins/module_utils/botocore.py b/plugins/module_utils/botocore.py index 791cac60333..3b37d6a7cbf 100644 --- a/plugins/module_utils/botocore.py +++ b/plugins/module_utils/botocore.py @@ -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') @@ -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'): @@ -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): diff --git a/plugins/module_utils/modules.py b/plugins/module_utils/modules.py index 6c1cc4c86a1..2bba3344bf7 100644 --- a/plugins/module_utils/modules.py +++ b/plugins/module_utils/modules.py @@ -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): @@ -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), diff --git a/tests/integration/targets/module_utils_core/aliases b/tests/integration/targets/module_utils_core/aliases index 4ef4b2067d0..d13ca049289 100644 --- a/tests/integration/targets/module_utils_core/aliases +++ b/tests/integration/targets/module_utils_core/aliases @@ -1 +1,4 @@ cloud/aws + +module_utils_botocore +module_utils_modules