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.

Error upload file. Use zappa+ lambda + s3 + django2 + RDS + Python 3.6

See original GitHub issue

When I save in local it keeps me well in S3 but when it is running with lamda I get the following error. I’ve used with django 1.11 and python 2.7 and it works fine `

Request Method: POST
https://s5h4s4t98f.execute-api.us-west-2.amazonaws.com/dev/admin/publicidad/publicidad/add/
2.1.1
ClientError
An error occurred (InvalidToken) when calling the PutObject operation: The provided token is malformed or otherwise invalid.
/var/runtime/botocore/client.py in _make_api_call, line 612
/var/lang/bin/python3.6
3.6.1
[‘/var/task’, ‘/var/runtime/awslambda’, ‘/var/runtime’, ‘/var/lang/lib/python36.zip’, ‘/var/lang/lib/python3.6’, ‘/var/lang/lib/python3.6/lib-dynload’, ‘/var/lang/lib/python3.6/site-packages’, ‘/var/task/setuptools-39.1.0-py3.6.egg’, ‘/var/task’]
Lun, 24 Sep 2018 00:27:27 -0500

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
ceefourcommented, Jan 7, 2019

This happens to me because AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY do not match with AWS_SESSION_TOKEN (see #68)

When using Zappa, do not provide your own access+secret key. Use the built-in ones given by AWS Lambda, including the session token. If you want to change the role, change your Lambda function’s IAM execution role.

1reaction
licht1steincommented, Nov 2, 2020

@ceefour thank you for the correct answer!

It is NOT about removing the variables from settings.py. The variables there must be mapped to the environment variables, that are automatically provided by lambda. So it has to be like:

AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
AWS_SECRET_ACCESS_KEY=os.environ['AWS_SECRET_ACCESS_KEY']

These keys are unique for every lambda deployment, bound to the IAM role that is used by lambda.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Zappa S3 Django Media Upload Times Out - Stack Overflow
I am trying to configure Zappa and Django to be able to upload media files but I am getting a weird permission error...
Read more >
Using Zappa and AWS Lambda to deploy serverless Django ...
Package your projects into Lambda-ready zip files and upload them to Amazon S3; Set up necessary AWS IAM roles and permissions; Deploy your ......
Read more >
Serve a Django App from an AWS Lambda Function - Blog
Learn how to deploy your Django app to a serverless architecture in AWS' free usage tier using Zappa, AWS CLI, IAM, Lambda, S3...
Read more >
zappa - PyPI
Server-less Python Web Services for AWS Lambda and API Gateway. ... Deploy or update your app using Zappa; Run $ zappa certify to...
Read more >
Serverless Django with Zappa on AWS Lambda - Blog Post
cd /path/to/your/dev/folder/ $ pipenv install --python 3.6 zappa django ... Below we'll use zappa init to create our zappa's settings file ...
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