Got an example for StepFunctions in troposphere?

94 views
Skip to first unread message

Mark McWiggins

unread,
May 6, 2020, 1:10:35 PM5/6/20
to cloudtools-dev
I must be missing something; I got a Glue node to work easily but trying to add step functions and I get

TypeError: Object of type 'module' is not JSON serializable


# glue node 'job' creation omitted ...


t.add_resource(job)

step.StartAt = job

step.StateMachine = step.StateMachine('myStep')

step.StateMachine.StateMachineName = "myStep"

step.StateMachine.RoleArn = "StatesExecutionRole"

step.title = "yobaby"

step.StateMachine.DefinitionString =        '''     {                                                                                                                                                 

              "Comment": "Glue Node Step Function",                                                                                                                                                   

              "StartAt": "GlueJob",                                                                                                                                                                   

              "States": {                                                                                                                                                                             

                "GlueJob":                                                                                                                                                                            

                  "Type": "Task",                                                                                                                                                                     

                  "Resource": "{glueArn}",                                                                                                                                                            

                  "End": true                                                                                                                                                                         

                }                                                                                                                                                                                     

              }                                                                                                                                                                                       

'''


t.add_resource(step)

print (t.to_yaml())


Any ideas on this? Thanks much.


Hugo Lopes Tavares

unread,
May 7, 2020, 9:28:10 AM5/7/20
to Mark McWiggins, cloudtools-dev
Can you share the whole traceback message or at least more info than just that one line?

I believe that error message indicates something is calling json.dumps() on a module instead of a compatible object. 


--
You received this message because you are subscribed to the Google Groups "cloudtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloudtools-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloudtools-dev/0ec3fd7a-db47-4814-9578-1458bbb6614b%40googlegroups.com.

Mark McWiggins

unread,
May 7, 2020, 1:22:34 PM5/7/20
to cloudtools-dev

Here you go; thanks much.


Traceback (most recent call last):

  File "./glue.py", line 38, in <module>

    print (t.to_yaml())

  File "/home/ubuntu/dbtry/lib/python3.6/site-packages/troposphere/__init__.py", line 793, in to_yaml

    return cfn_flip.to_yaml(self.to_json(), clean_up=clean_up,

  File "/home/ubuntu/dbtry/lib/python3.6/site-packages/troposphere/__init__.py", line 790, in to_json

    sort_keys=sort_keys, separators=separators)

  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps

    **kw).encode(obj)

  File "/usr/lib/python3.6/json/encoder.py", line 201, in encode

    chunks = list(chunks)

  File "/usr/lib/python3.6/json/encoder.py", line 430, in _iterencode

    yield from _iterencode_dict(o, _current_indent_level)

  File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict

    yield from chunks

  File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict

    yield from chunks

  File "/usr/lib/python3.6/json/encoder.py", line 437, in _iterencode

    o = _default(o)

  File "/usr/lib/python3.6/json/encoder.py", line 180, in default

    o.__class__.__name__)

TypeError: Object of type 'module' is not JSON serializable


To unsubscribe from this group and stop receiving emails from it, send an email to cloudto...@googlegroups.com.

Hugo Lopes Tavares

unread,
May 7, 2020, 9:57:31 PM5/7/20
to Mark McWiggins, cloudtools-dev
Sorry, I can't pinpoint where the problem is,
but here are a few suggestions:

* add calls to t.to_yaml() after all t.add_resource(...) calls and the first to fail is where you should focus

* check your troposphere objects looking for properties that use objects that look like module names you imported earlier (it's easy to name a variable json and import json too) 

* search for all modules you imported at the top of the file and look for odd places using a module (text search)

Good luck! 







To unsubscribe from this group and stop receiving emails from it, send an email to cloudtools-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloudtools-dev/13a28089-3508-4c46-ab72-a9907c1bbe81%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages