By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Method not available for boto3.client('transfer') in Lambda Python Function

0

Hi, I am unable to access the list_file_transfer_results method for the boto3.client('transfer') object. After running the following code

s3 = boto3.client('s3')
transfer_client = boto3.client('transfer')

response = transfer_client.list_file_transfer_results(
ConnectorId='c-top-secret',
 TransferId=TransferId
 )

Receive the error of 'Transfer' object has no attribute 'list_file_transfer_results'

According to AWS documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transfer/client/list_file_transfer_results.html it should exist.

Interestingly when running code to list all methods of the client object

print(dir(transfer_client))

it produces the following :

['_PY_TO_OP_NAME', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_cache', '_client_config', '_convert_to_request_dict', '_emit_api_params', '_endpoint', '_exceptions', '_exceptions_factory', '_get_credentials', '_get_waiter_config', '_load_exceptions', '_loader', '_make_api_call', '_make_request', '_register_handlers', '_request_signer', '_resolve_endpoint_ruleset', '_response_parser', '_ruleset_resolver', '_serializer', '_service_model', '_user_agent_creator', 'can_paginate', 'close', 'create_access', 'create_agreement', 'create_connector', 'create_profile', 'create_server', 'create_user', 'create_workflow', 'delete_access', 'delete_agreement', 'delete_certificate', 'delete_connector', 'delete_host_key', 'delete_profile', 'delete_server', 'delete_ssh_public_key', 'delete_user', 'delete_workflow', 'describe_access', 'describe_agreement', 'describe_certificate', 'describe_connector', 'describe_execution', 'describe_host_key', 'describe_profile', 'describe_security_policy', 'describe_server', 'describe_user', 'describe_workflow', 'exceptions', 'generate_presigned_url', 'get_paginator', 'get_waiter', 'import_certificate', 'import_host_key', 'import_ssh_public_key', 'list_accesses', 'list_agreements', 'list_certificates', 'list_connectors', 'list_executions', 'list_host_keys', 'list_profiles', 'list_security_policies', 'list_servers', 'list_tags_for_resource', 'list_users', 'list_workflows', 'meta', 'send_workflow_step_state', 'start_directory_listing', 'start_file_transfer', 'start_server', 'stop_server', 'tag_resource', 'test_connection', 'test_identity_provider', 'untag_resource', 'update_access', 'update_agreement', 'update_certificate', 'update_connector', 'update_host_key', 'update_profile', 'update_server', 'update_user', 'waiter_names']

Notice that list_file_transfer_results is missing !

Possible conclusions:

  • Running wrong version of Python (python_version = 3.12.7)
  • Boto3 has this method removed for the ap-southeast-2 region
  • The method has been depreciated, but AWS documentation not updated.

Any suggestions are warmly welcome!

asked 20 days ago50 views
2 Answers
0

The issue you're experiencing is likely due to an outdated version of the boto3 library in your Lambda function's environment. The list_file_transfer_results method is a relatively new addition to the AWS Transfer Family service, and it may not be available in older versions of boto3.

To resolve this, you should try the following steps:

  1. Update the boto3 library in your Lambda function. You can do this by including the latest version of boto3 in your deployment package. Create a requirements.txt file with the following content:

    boto3==latest
    

    Then, install the dependencies in a directory that you'll include in your Lambda deployment package:

    pip install -r requirements.txt -t ./package
    
  2. Include the updated boto3 library in your Lambda deployment package along with your function code.

  3. If you're using a Lambda layer for boto3, make sure it's updated to the latest version.

  4. After updating boto3, redeploy your Lambda function.

It's important to note that AWS regularly updates their services and SDKs, and the documentation you're referring to might be for the latest version. Always ensure that your boto3 version is up-to-date to access the most recent features and methods.

If updating boto3 doesn't resolve the issue, you may want to double-check that the AWS Transfer Family service fully supports this method in your specific region (ap-southeast-2). Although it's unlikely, there could be regional differences in feature availability.

Lastly, make sure your IAM role for the Lambda function has the necessary permissions to use the AWS Transfer Family service and specifically the list_file_transfer_results action.

If the problem persists after trying these steps, you may want to contact AWS support for further assistance, as there could be an underlying issue specific to your account or setup.
Sources
Working with AWS Boto3 - Amazon Braket
Code examples for Lambda using AWS SDKs - AWS Lambda
AWS client not reused in a Lambda function | Amazon CodeGuru, Detector Library

profile picture
answered 20 days ago
  • Have noted the following regarding Boto3 version

    In the documentation, Boto3 version is Boto3 1.35.63 In the Lambda Python function, Boto3 version is boto3 version: 1.34.145 In the AWS CLI, Boto3 version is boto3 1.35.20

    Considering that AWS CLI is working (eg aws transfer list-file-transfer-results --connector-id c-top-screct --transfer-id -454532452345top-works), suggests need to have at least boto31.35.20 version running on Lambda. So will need to create a Lambda deployment package ! WOW !

0

I think you should using this method instead:

response = client.list_executions(
    MaxResults=123,
    NextToken='string',
    WorkflowId='string'
)

Here is response:

{
    'NextToken': 'string',
    'WorkflowId': 'string',
    'Executions': [
        {
            'ExecutionId': 'string',
            'InitialFileLocation': {
                'S3FileLocation': {
                    'Bucket': 'string',
                    'Key': 'string',
                    'VersionId': 'string',
                    'Etag': 'string'
                },
                'EfsFileLocation': {
                    'FileSystemId': 'string',
                    'Path': 'string'
                }
            },
            'ServiceMetadata': {
                'UserDetails': {
                    'UserName': 'string',
                    'ServerId': 'string',
                    'SessionId': 'string'
                }
            },
            'Status': 'IN_PROGRESS'|'COMPLETED'|'EXCEPTION'|'HANDLING_EXCEPTION'
        },
    ]
}

Refs: https://boto3.amazonaws.com/v1/documentation/api/1.35.6/reference/services/transfer/client/list_executions.html

profile picture
answered 20 days ago
  • Many thanks for your suggestion, having a go. I am having difficulty getting the WorkflowID.

    For example,

        response = transfer_client.start_file_transfer(
        ConnectorId='c-top-secret',
        SendFilePaths = files_to_upload,
        RemoteDirectoryPath= myRemoteDirectoryPath
        )
    
        # List workflows
        response = transfer_client.list_workflows()
    
        print("Response for list_workflows : " + json.dumps(response, indent=2))
    

    Produces the following json response:

    {
    "Workflows": [],
    "ResponseMetadata": {
        "RequestId": "f8bc7d94-e77d-40be-9fe4-747ebc8e844f",
        "HTTPStatusCode": 200,
        "HTTPHeaders": {
        "date": "Mon, 18 Nov 2024 21:10:24 GMT",
        "content-type": "application/x-amz-json-1.1",
        "content-length": "16",
        "connection": "keep-alive",
        "x-amzn-requestid": "f8bc7d94-e77d-40be-9fe4-747ebc8e844f"
        },
        "RetryAttempts": 0
    }
    }
    

    Note, no workflowID

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions