From 089c7db741dc09c066107b8e06e4da66bfb79d06 Mon Sep 17 00:00:00 2001 From: Geoffrey Hichborn Date: Mon, 29 Aug 2022 17:16:33 -0700 Subject: [PATCH 1/4] Fix detection of ssm connection bucket region by ensuring that the boto client is created normally and able to use supported credential sources --- plugins/connection/aws_ssm.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/connection/aws_ssm.py b/plugins/connection/aws_ssm.py index 79bea085ad6..3734d64c938 100644 --- a/plugins/connection/aws_ssm.py +++ b/plugins/connection/aws_ssm.py @@ -534,12 +534,14 @@ def _flush_stderr(self, subprocess): def _get_url(self, client_method, bucket_name, out_path, http_method, profile_name, extra_args=None): ''' Generate URL for get_object / put_object ''' - bucket_location = boto3.client('s3').get_bucket_location( + region_name = self.get_option('region') or 'us-east-1' + + bucket_location = self._get_boto_client('s3', region_name=region_name, profile_name=profile_name).get_bucket_location( Bucket=(self.get_option('bucket_name')), ) - region_name = bucket_location['LocationConstraint'] + bucket_region_name = bucket_location['LocationConstraint'] - client = self._get_boto_client('s3', region_name=region_name, profile_name=profile_name) + client = self._get_boto_client('s3', region_name=bucket_region_name, profile_name=profile_name) params = {'Bucket': bucket_name, 'Key': out_path} if extra_args is not None: params.update(extra_args) From 782752fa2b1a892b74730648a0fdaa6f02c54345 Mon Sep 17 00:00:00 2001 From: Geoffrey Hichborn Date: Mon, 29 Aug 2022 17:23:40 -0700 Subject: [PATCH 2/4] Add doc fragment --- changelogs/fragments/1428-aws-ssm-missing-credentials.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/1428-aws-ssm-missing-credentials.yml diff --git a/changelogs/fragments/1428-aws-ssm-missing-credentials.yml b/changelogs/fragments/1428-aws-ssm-missing-credentials.yml new file mode 100644 index 00000000000..308e011486c --- /dev/null +++ b/changelogs/fragments/1428-aws-ssm-missing-credentials.yml @@ -0,0 +1,2 @@ +bugfixes: + - aws_ssm - fixes S3 bucket region detection by ensuring boto client has correct credentials and exists in correct partition From 72ab082d679c2886713daf4b63dc40e82b19605c Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Tue, 18 Oct 2022 15:04:24 +0200 Subject: [PATCH 3/4] Update changelog Co-authored-by: Markus Bergholz --- changelogs/fragments/1428-aws-ssm-missing-credentials.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/1428-aws-ssm-missing-credentials.yml b/changelogs/fragments/1428-aws-ssm-missing-credentials.yml index 308e011486c..72debfc70dc 100644 --- a/changelogs/fragments/1428-aws-ssm-missing-credentials.yml +++ b/changelogs/fragments/1428-aws-ssm-missing-credentials.yml @@ -1,2 +1,2 @@ bugfixes: - - aws_ssm - fixes S3 bucket region detection by ensuring boto client has correct credentials and exists in correct partition + - aws_ssm - fixes S3 bucket region detection by ensuring boto client has correct credentials and exists in correct partition (https://github.com/ansible-collections/community.aws/pull/1428/files). From 8774daa00bdfa7cd804386c5b09e34ace17f41fc Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Tue, 18 Oct 2022 15:05:01 +0200 Subject: [PATCH 4/4] Update changelog --- changelogs/fragments/1428-aws-ssm-missing-credentials.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/1428-aws-ssm-missing-credentials.yml b/changelogs/fragments/1428-aws-ssm-missing-credentials.yml index 72debfc70dc..49092b9ae18 100644 --- a/changelogs/fragments/1428-aws-ssm-missing-credentials.yml +++ b/changelogs/fragments/1428-aws-ssm-missing-credentials.yml @@ -1,2 +1,2 @@ bugfixes: - - aws_ssm - fixes S3 bucket region detection by ensuring boto client has correct credentials and exists in correct partition (https://github.com/ansible-collections/community.aws/pull/1428/files). + - aws_ssm - fixes S3 bucket region detection by ensuring boto client has correct credentials and exists in correct partition (https://github.com/ansible-collections/community.aws/pull/1428).