I am trying to connect my onion omega2+ to send data payloads to my aws dynamodb.
I have my credentials setup in .aws directory of the home user.
The exact same setup works from my ubuntu laptop and all of my rpi3's as well as all venv's that I have tried on other devices.
I have tried running the code as boto3.resource and boto3.client - I have tried running the code on different linux devices and they all run the code and send the payload to my aws dynamodb.
The only real difference between platforms is the omega2+ runs on an openwrt os which maybe the issue? As this is the only real difference I can think of between the platforms that is different.
import boto3
boto3.set_stream_logger('botocore', level='DEBUG')
dynamodb = boto3.resource('dynamodb')
#dynamodb = boto3.client('dynamodb') # test client output
dynamoTable = dynamodb.Table('test_table')
dynamoTable.put_item(
Item={
'Name': 'Dante',
'Age': '25',
'Location': 'Armidale'
}
)
OUTPUT from omega2+
2019-09-05 05:31:27,369 botocore.hooks [DEBUG] Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-09-05 05:31:27,687 botocore.hooks [DEBUG] Changing event name from before-call.apigateway to before-call.api-gateway
2019-09-05 05:31:27,721 botocore.hooks [DEBUG] Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-09-05 05:31:27,889 botocore.hooks [DEBUG] Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-09-05 05:31:27,899 botocore.hooks [DEBUG] Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-09-05 05:31:27,939 botocore.hooks [DEBUG] Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-09-05 05:31:27,999 botocore.hooks [DEBUG] Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-09-05 05:31:28,233 botocore.hooks [DEBUG] Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-09-05 05:31:28,244 botocore.hooks [DEBUG] Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-09-05 05:31:28,250 botocore.hooks [DEBUG] Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-09-05 05:31:28,257 botocore.hooks [DEBUG] Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/session.py", line 341, in resource
File "/usr/lib/python3.6/site-packages/botocore/loaders.py", line 132, in _wrapper
data = func(self, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/botocore/loaders.py", line 378, in load_service_model
known_service_names=', '.join(sorted(known_services)))
botocore.exceptions.UnknownServiceError: Unknown service: 'dynamodb'. Valid service names are:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "boto3_aws.py", line 10, in <module>
dynamodb = boto3.resource('dynamodb')
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/__init__.py", line 100, in resource
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/session.py", line 347, in resource
boto3.exceptions.ResourceNotExistsError: The 'dynamodb' resource does not exist.
The available resources are:
-
Consider using a boto3.client('dynamodb') instead of a resource for 'dynamodb'
For simplicity's sake, I created a user on the onion omega2+ with ssh access. I added a password for the user and created a /home/username with correct user permissions for the new user. I then added my credentials into a hidden folder in my user directory /home/username/.aws
I then uninstalled boto3 v1.9.219 and downgrade it to boto3 v1.9.164 using pip3.
To remove offending version of boto3:
pip3 uninstall boto3==1.9.219
Install downgraded version of boto3:
pip3 install boto3==1.9.164
Leaving all other files and credential information in tact, the script above connected to my aws dynamodb and added the item put information correctly into my test dynamodb.
You can use pip3 list or your python3 console to find out what version of boto3 is currently installed before making changes. To confirm the downgraded version was installed, my output after downgrading is below.
>>> import boto3
>>> print(boto3.__version__)
1.9.164
>>>