diff --git a/changelogs/fragments/623-aws_ssm-envars.yml b/changelogs/fragments/623-aws_ssm-envars.yml new file mode 100644 index 00000000000..a310fa1e990 --- /dev/null +++ b/changelogs/fragments/623-aws_ssm-envars.yml @@ -0,0 +1,5 @@ +minor_changes: +- aws_ssm: Add support for ``endpoint`` parameter (https://github.com/ansible-collections/amazon.aws/pull/623). + +bugfixes: +- aws_ssm: Fix environment variables for client configuration (e.g., AWS_PROFILE, AWS_ACCESS_KEY_ID) (https://github.com/ansible-collections/amazon.aws/pull/623). diff --git a/plugins/lookup/aws_ssm.py b/plugins/lookup/aws_ssm.py index 997bfb36227..d533702decb 100644 --- a/plugins/lookup/aws_ssm.py +++ b/plugins/lookup/aws_ssm.py @@ -68,7 +68,7 @@ choices: ['error', 'skip', 'warn'] version_added: 2.0.0 endpoint: - description: Use a custom endpoint when connecting to SSM service + description: Use a custom endpoint when connecting to SSM service. type: string version_added: 3.4.0 extends_documentation_fragment: @@ -211,15 +211,7 @@ def run(self, terms, variables=None, boto_profile=None, aws_profile=None, endpoint=cli_endpoint, )) - try: - client = boto3_conn(module=self, **cli_boto_params) - except ( - botocore.exceptions.ProfileNotFound, - botocore.exceptions.PartialCredentialsError, - botocore.exceptions.ClientError, - botocore.exceptions.ParamValidationError, - ): - raise AnsibleError("Insufficient credentials found.") + client = boto3_conn(module=self, **cli_boto_params) ssm_dict['WithDecryption'] = decrypt @@ -274,9 +266,6 @@ def get_path_parameters(self, client, ssm_dict, term, on_missing, on_denied): return paramlist - def fail_json(self, msg, **kwargs): - raise AnsibleError(msg) - def get_parameter_value(self, client, ssm_dict, term, on_missing, on_denied): ssm_dict["Name"] = term try: diff --git a/tests/unit/plugins/lookup/test_aws_ssm.py b/tests/unit/plugins/lookup/test_aws_ssm.py index 5bbd11a6aed..b224740a693 100644 --- a/tests/unit/plugins/lookup/test_aws_ssm.py +++ b/tests/unit/plugins/lookup/test_aws_ssm.py @@ -18,10 +18,11 @@ # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) -from unittest.mock import ANY + __metaclass__ = type import pytest +from unittest.mock import ANY from copy import copy from ansible.errors import AnsibleError