Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/1428-aws-ssm-missing-credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +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).
8 changes: 5 additions & 3 deletions plugins/connection/aws_ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down