Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] - SyntaxError when using Python, boto3 and s3 #59

Closed
maoo opened this issue Aug 16, 2017 · 3 comments
Closed

[Question] - SyntaxError when using Python, boto3 and s3 #59

maoo opened this issue Aug 16, 2017 · 3 comments

Comments

@maoo
Copy link

maoo commented Aug 16, 2017

Apologies in advance if this is not the right place to open this issue, I don't have an extensive experience with aws-sam-local or Python, so I may be missing something really stupid.

I have a problem with my simple sam function; assuming that test.py and template.yaml are in the current folder, the issue can be reproduced by simply running echo '{}' | sam local invoke Test.

The error I get is SyntaxError: invalid syntax on line client = boto3.client('s3') - full history on https://gist.github.com/maoo/2175a1c4b75a80c7271943591afb4920#file-error-log

The interesting part is that running the same function without sam, everything works; assuming that test.py and template.yaml are in the current folder, you can test the following command...

pip install boto3 -t .
python -c 'from test import test1; test1(None,None)'

... which expects to return an error saying The specified key does not exist.

@rafaharo
Copy link

Seems that your test scripts is not using standard spaces as separator (you have probably used the tab within a text editor and not a proper Python IDE). Not sure, but could be that taking quick a look at the raw file

@maoo
Copy link
Author

maoo commented Aug 16, 2017

Thanks @rafaharo , I've tried to use spaces across the test.py file, but got the same result; I suppose that - if it was an indentation issue - also the python -c command would fail.

@maoo
Copy link
Author

maoo commented Aug 16, 2017

Fixed the issue by using python2.7 as Runtime in template.yaml (see https://gist.github.com/maoo/2175a1c4b75a80c7271943591afb4920#file-template-yaml-L10)

I'll close the issue here and post it to https://github.com/boto/boto3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants