question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

botocore.exceptions.DataNotFoundError: Unable to load data for: ec2/2016-09-15/service-2

See original GitHub issue

This issue started happening when we upgraded to boto3 1.4.1. When we try to create a ec2 resource from a boto3 session, we are getting this error botocore.exceptions.DataNotFoundError: Unable to load data for: ec2/2016-09-15/service-2

The code we use to reproduce this issue is

import boto3
role_arn_to_assume = 'arn:aws:iam::xxxxxxxxxx:role/some-role-name'
sts_client = boto3.client('sts')
assumed_role = sts_client.assume_role(
            RoleArn=role_arn_to_assume,
            RoleSessionName='some-session-name'
 )
new_creds = assumed_role['Credentials']
session_args = {
            'aws_access_key_id': new_creds['AccessKeyId'],
            'aws_secret_access_key': new_creds['SecretAccessKey'],
            'aws_session_token': new_creds['SessionToken'],
}
session = boto3.session.Session(**session_args)
ec2_resource = session.resource('ec2')

When I run this code with 1.4.1, it gives the following error:

Traceback (most recent call last):
  File "/my/folder/workspace/my_script.py", line xxx, in <module>
    ec2_resource = session.resource('ec2')
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/boto3/session.py", line 389, in resource
    aws_session_token=aws_session_token, config=config)
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/botocore/session.py", line 824, in create_client
    client_config=config, api_version=api_version)
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/botocore/client.py", line 61, in create_client
    service_model = self._load_service_model(service_name, api_version)
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/botocore/client.py", line 91, in _load_service_model
    api_version=api_version)
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/botocore/loaders.py", line 123, in _wrapper
    data = func(self, *args, **kwargs)
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/botocore/loaders.py", line 358, in load_service_model
    return self.load_data(full_path)
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/botocore/loaders.py", line 123, in _wrapper
    data = func(self, *args, **kwargs)
  File "/my/folder/my-virtualenv/lib/python2.7/site-packages/botocore/loaders.py", line 382, in load_data
    raise DataNotFoundError(data_path=name)
botocore.exceptions.DataNotFoundError: Unable to load data for: ec2/2016-09-15/service-2

If I run it with previous release 1.4.0, it works fine.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
asaedcommented, Oct 13, 2016

Some other teammates found that this error even happens with simple code like

import boto3 
boto3.resource('ec2') 

the workaround they found was to rewrite that line to be

import boto3 
boto3.resource('ec2', region_name='us-east-1', api_version='2016-04-01') 
2reactions
monkutcommented, Aug 3, 2018

I had a similar DataNotFoundError with the kinesis client, where the erroring item was endpoints.

  File "/var/task/boto3/session.py", line 263, in client
  aws_session_token=aws_session_token, config=config)
  File "/var/task/botocore/session.py", line 875, in create_client
  endpoint_resolver = self._get_internal_component('endpoint_resolver')
  File "/var/task/botocore/session.py", line 744, in _get_internal_component
  return self._internal_components.get_component(name)
  File "/var/task/botocore/session.py", line 946, in get_component
  self._components[name] = factory()
  File "/var/task/botocore/session.py", line 191, in create_default_resolver
  endpoints = loader.load_data('endpoints')
  File "/var/task/botocore/loaders.py", line 132, in _wrapper
  data = func(self, *args, **kwargs)
  File "/var/task/botocore/loaders.py", line 424, in load_data
  raise DataNotFoundError(data_path=name)
botocore.exceptions.DataNotFoundError: Unable to load data for: endpoints

Adding api_version='2016-04-01' to the client instaniation did not help…

Read more comments on GitHub >

github_iconTop Results From Across the Web

botocore.exceptions.DataNotFoundError: Unable to load ...
The DataNotFoundError exception is very misleading but is indeed caused by your failure to provide keyword arguments correctly.
Read more >
boto3 S3 in Windows COM object
I've worked around the problem where boto3 needs to know where some external files: ... DataNotFoundError: Unable to load data for: endpoints
Read more >
boto/boto3 - Gitter
Greetings, I am newbie on boto3 sdk on AWS AMI, I tried to run basic s3 service, but seeing "botocore.exceptions.ClientError: An error occurred...
Read more >
Boto3 and PyInstaller – Getting DataNotFoundError only in ...
Hi, I'm working on a project in python that uses boto3 and I've recently come across an issue ... DataNotFoundError: Unable to load...
Read more >
Python botocore.exceptions.DataNotFoundError() Examples
def load_data(self, name): """Load data given a data path. This is a low level method that will search through the various search paths...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found