I'm not sure if the problem I am facing is a lack of experience with Python or an error in the interpreter, but I think that I am receiving a TypeError message on the wrong line.
Please explain to me why this happens if it is not a mistake. My code is as follows:
#!/usr/bin/env python3 from awacs.aws import Policy, Principal, Statement from troposphere import Template from troposphere.iam import Role t = Template() t.add_resource(Role( "SESLambdaRole", AssumeRolePolicyDocument = Policy( Version = "2012-10-17", Statement = [ Statement( Effect = "Allow", Resource = "arn:aws:logs:*:*:*", Principal = Principal( "Service", ["lambda.amazonaws.com"] ), ) ] ) )) print(t.to_json())
This is my conclusion.
ubuntu@ip-111-11-11-111 :~$ ./ses-lambda-forwarder-resources.py Traceback (most recent call last): File "./ses-lambda-forwarder-resources.py", line 19, in <module> ["lambda.amazonaws.com"] File "/home/ubuntu/.local/lib/python3.6/site-packages/awacs/__init__.py", line 113, in __init__ sup.__init__(None, props=self.props, **kwargs) File "/home/ubuntu/.local/lib/python3.6/site-packages/awacs/__init__.py", line 40, in __init__ self.__setattr__(k, v) File "/home/ubuntu/.local/lib/python3.6/site-packages/awacs/__init__.py", line 81, in __setattr__ self._raise_type(name, value, expected_type) File "/home/ubuntu/.local/lib/python3.6/site-packages/awacs/__init__.py", line 90, in _raise_type (name, type(value), expected_type)) TypeError: Resource is <class 'str'>, expected <class 'list'> ubuntu@ip-111-11-11-111 :~$ python3
If I change the following line
Resource = "arn:aws:logs:*:*:*",
to
Resource = [ "arn:aws:logs:*:*:*" ],
It works. Why is Python complaining about line 3 of the line below?