Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

[Enhancement] Modify the write location to /tmp/ directory so that fuelsdk can be utilized in aws lambda #128

@cheneyshreve

Description

@cheneyshreve

Is your feature request related to a problem? Please describe
A clear and concise description of what the problem is.
I deployed a lambda function that uses fuelsdk-python to authenticate with salesforce marketing cloud api, retrieve data from a data extension, and peform pagination. This works brilliantly when running locally using pure python. When I deploy the logic within an aws python function, using the serverless framework, I get the error below when I execute the function. As a side note, I could never get this to work locally using environment variables, but it always works when I use phyton.config so I deploy to a private aws bucket that does not permit public access. The lamba function itself, however, does have adequate permissions to read/write to the relevant s3 buckets. I believe the error below is down to the fact that aws lambda will only let you write to '/tmp/' directory, so it might be just a very quick code update to do this.

  "errorMessage": "[Errno 30] Read-only file system: '/var/task/FuelSDK/ExactTargetWSDL.xml'",
  "errorType": "OSError",
  "stackTrace": [
    "  File \"/var/task/handler.py\", line 112, in paginate\n    myClient = ET_Client.ET_Client()\n",
    "  File \"/var/task/FuelSDK/client.py\", line 56, in __init__\n    self.configure_client(get_server_wsdl, params, tokenResponse)\n",
    "  File \"/var/task/FuelSDK/client.py\", line 130, in configure_client\n    self.wsdl_file_url = self.load_wsdl(wsdl_server_url, wsdl_file_local_location, get_server_wsdl)\n",
    "  File \"/var/task/FuelSDK/client.py\", line 224, in load_wsdl\n    self.retrieve_server_wsdl(wsdl_url, file_location)\n",
    "  File \"/var/task/FuelSDK/client.py\", line 241, in retrieve_server_wsdl\n    f = open(file_location, 'w')\n"
  ]
}

I think the resolution, for aws lambda, would just be to modify line 241 of client.py

f = open(file_location, 'w')

modification would likely need to be this, because this is similar to how you write to s3 buckets via lambda:
f = open('/tmp/'+ file_location, 'w')

I'm uncertain, if I were to clone this repo and make the modification locally for reference, how I would
then reference that via the traditional requirements route (e.g. using pip and requirements.txt that are
utilized by aws lambda).

Describe the solution you'd like
A clear and concise description of what you want to happen.
to be able to use fuelsdk-python within aws lambda function

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
deploying with amplify or another route on aws. lambda has much greater cost benefits.

Additional context
Add any other context or screenshots about the feature request here.
I'd be happy to contribute if someone can point me in the right direction. The fuelsdk is really valuable to the work that I'm doing and it would be amazing to be able to use it with aws lambda.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions