Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for SQS Sensor when configured credentials are 'None' #113

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kylestewart
Copy link

Purpose

We are using an IAM Role on the node running StackStorm and despite the documentation saying None can be specified for the aws_access_key_id and aws_secret_access_key, we were not able to get this to work. Upon registering the sensor we would see this traceback in our logs:

2021-05-19 19:40:27,714 WARNING [-] Sensor "AWSSQSSensor" run method raised an exception: An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid..
Traceback (most recent call last):
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py", line 240, in run
self._sensor_instance.run()
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/sensor/base.py", line 122, in run
self.poll()
File "/opt/stackstorm/packs/aws/sensors/sqs_sensor.py", line 69, in poll
self._may_setup_sqs()
File "/opt/stackstorm/packs/aws/sensors/sqs_sensor.py", line 131, in _may_setup_sqs
self._setup_session()
File "/opt/stackstorm/packs/aws/sensors/sqs_sensor.py", line 179, in _setup_session
self.account_id = session.client('sts').get_caller_identity().get('Account')
File "/opt/stackstorm/virtualenvs/aws/lib/python3.6/site-packages/botocore/client.py", line 251, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/opt/stackstorm/virtualenvs/aws/lib/python3.6/site-packages/botocore/client.py", line 537, in _make_api_call
raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid.

The sensor would then shut down and our messages would not get handled.

Approach

Adding a simple IF statement to help translate the string value of 'None' in the config to the null Python object None resolved the issue for us.

@CLAassistant
Copy link

CLAassistant commented May 11, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ kylestewart
❌ Kyle Stewart


Kyle Stewart seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants