Does boto3 v1.9.244 support creating an 's3' resource?

boto3 version
boto3.client example
boto3 github
boto vs boto3
boto3 s3
boto3 ec2
aws python boto3 scripts
boto3 examples

I am attempting to retrieve a list of files from S3 with a specific prefix using an AWS Lambda. I bundle the Lambda with boto3-1.9.244 (the latest version). When I run the Lambda, I receive a SyntaxError on the S3 resource assignment although it could have something to do with Boto3 session.

I'm using Python 3.6 and AWS Lambda uses boto3-1.9.221 and botocore-1.12.221. When I run the code without bundling the latest version of boto3, it works. My current solution is to simply bundle boto3-1.9.221 with the lambda code rather than the latest version of boto3.

import boto3

s3 = boto3.resource('s3')

I expect it to create an s3 resource, but I get this error:

invalid syntax (_base.py, line 414): SyntaxError
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 20, in lambda_handler
    s3 = boto3.resource('s3')
  File "/var/task/boto3/__init__.py", line 100, in resource
    return _get_default_session().resource(*args, **kwargs)
  File "/var/task/boto3/session.py", line 389, in resource
    aws_session_token=aws_session_token, config=config)
  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 839, in create_client
    client_config=config, api_version=api_version)
  File "/var/task/botocore/client.py", line 80, in create_client
    cls = self._create_client_class(service_name, service_model)
  File "/var/task/botocore/client.py", line 110, in _create_client_class
    base_classes=bases)
  File "/var/task/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/var/task/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/var/task/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/var/task/boto3/utils.py", line 61, in _handler
    module = import_module(module)
  File "/var/task/boto3/utils.py", line 52, in import_module
    __import__(name)
  File "/var/task/boto3/s3/inject.py", line 15, in <module>
    from boto3.s3.transfer import create_transfer_manager
  File "/var/task/boto3/s3/transfer.py", line 127, in <module>
    from s3transfer.exceptions import RetriesExceededError as \
  File "/var/task/s3transfer/__init__.py", line 134, in <module>
    import concurrent.futures
  File "/var/task/concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/var/task/concurrent/futures/_base.py", line 414
    raise exception_type, self._exception, self._traceback
                        ^
SyntaxError: invalid syntax

Yes, it does support. So this issue is not related to the API version.

You can access a specific API version just by replacing latest with the version number you want in the URL.

Latest

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#bucket

1.9.244

https://boto3.amazonaws.com/v1/documentation/api/1.9.244/reference/services/s3.html#bucket

Does boto3 v1.9.244 support creating an 's3' resource? – Onooks, When I run the Lambda, I receive a SyntaxError on the S3 resource assignment although it could have something to do with Boto3 session. The title of the AWS Support case. The title appears in the Subject field on the AWS Support Center Create Case page. serviceCode (string) -- The code for the AWS service. You can use the DescribeServices operation to get the possible serviceCode values. severityCode (string) -- A value that indicates the urgency of the case.


Turns out the issue was that I was installing the requirements with Python2 rather than Python3. By installing the requirements with Python3, I no longer received a syntax error.

Boto3 documentation, Boto is the Amazon Web Services (AWS) SDK for Python. It enables Python developers to create, configure, and manage AWS services, such as EC2 and S3​. Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2. You can find the latest, most up to date, documentation at our doc site , including a list of services that are supported.


It looks like your lambda function doesn't have the IAM role for S3. You may specify the Access key and Secret key to the resource directly,

resource = boto3.resource(
    's3',
    # Hard coded strings as credentials, not recommended.
    aws_access_key_id='AKIAIO5FODNN7E******', # not real
    aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYE******' # not real
)

or have to give the right permission to the lambda function.

Boto 3 Documentation, Boto is the Amazon Web Services (AWS) SDK for Python, which allows Python developers to write Boto provides an easy to use, object-oriented API as well as low-level direct service access. Step 3: Set Up Credentials · Step 4: Install Boto 3 · Step 5: Download Example Code · Step 6: Run and Debug Code · Next Steps. Boto3 documentation¶ Boto is the Amazon Web Services (AWS) SDK for Python. It enables Python developers to create, configure, and manage AWS services, such as EC2 and S3. Boto provides an easy to use, object-oriented API, as well as low-level access to AWS services.


Quickstart, Quickstart¶. Getting started with Boto3 is easy, but requires a few steps. Before you can begin using Boto3, you should set up authentication credentials. Credentials for For example, the following uploads a new file to S3. Does boto3 support creating directory ? Will it create a directory name "dir" when I put an object with a key such as "dir/file.png" ? 😄 1


AWS SDK for Python (Boto3), For example, you can start an Amazon EC2 instance and use a waiter to wait until it reaches the 'running' state, or you can create a new Amazon DynamoDB  How long in minutes, from 5 to 480 (8 hours), for AWS CodeBuild to wait until timing out any related build that does not get marked as completed. The default is 60 minutes. AutoCreateApplication ( boolean ) -- Set to true to create an application with the specified name if it doesn't already exist.


A Python interface to Amazon Web Services, Currently, all features work with Python 2.6 and 2.7. Work is under way to support Python 3.3+ in the same codebase. Modules are being ported one at a time  class boto3.session. Session ( aws_access_key_id=None , aws_secret_access_key=None , aws_session_token=None , region_name=None , botocore_session=None , profile_name=None ) [source] ¶ A session stores configuration state and allows you to create service clients and resources.