community.aws
community.aws copied to clipboard
Throw hidden AWS SSM errors
Summary
While setting up this plugin, it's common to run into issues with the AWS s3 requests used to talk to the bucket that stores temporary files for transfer between servers.
A file which is automatically generated using the curl request will have syntax errors if the request fails, leading to an "invalid syntax" error. (e.g. home/ssm-user/.ansible/tmp/ansible-tmp-1594113678.8116896-25457-211691010476604/AnsiballZ_setup.py
)
An example is in this issue where the OP had to dig in to figure out what was in the file.
It would be prudent to catch the invalid syntax error in that file (and any other automatically generated files) and throw the error with the contents of the file.
As requests can fail for various reasons, checking the contents of the file all the time is not sustainable. In my case I had two distinct failures and could only figure it out by modifying the plugin manually to write to a different file.
Examples of the errors:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AuthorizationQueryParametersError</Code><Message>Error parsing the X-Amz-Credential parameter; the region 'eu-west-2' is wrong; expecting 'eu-west-1'</Message><Region>eu-west-1</Region><RequestId>R1B1BXGJ5CNB0X6P</RequestId><HostId>xxxxxxxx</HostId></Error>sh-4.2
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>TemporaryRedirect</Code><Message>Please re-send this request to the specified temporary endpoint. Continue to use the original request endpoint for future requests.</Message><Endpoint>ansible-files.s3.eu-west-2.amazonaws.com</Endpoint><Bucket>ansible-ssm-session-files</Bucket><RequestId>NRSD6TBY3NDB5HEB</RequestId><HostId>xxxxxxxxx</HostId></Error>
Issue Type
Feature Idea
Component Name
ssm
Additional Information
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
Files identified in the description: None
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.