After constructing a cloudformation.Template object there are two main classes of APIs available. The first is a dict/set-like API to Description, Mappings, Outputs, Parameters, and Resources. Description should be get and set as a string property. The rest may be treated like dictionaries or sets via the add method, which takes a key and arbitrary keyword arguments. These data structures will be faithfully reproduced in the JSON output.

EC2 user data is handled separately. The add_user_data method accepts a file-like object which it reads, parses, and stores for later. The parsing step is very rudimentary: it splits the input on "____". Later, the ref_user_data method will replace the "____" markers with its positional parameters in the order they appear. Use ref_user_data as the value of the UserData key in the Properties dictionary of a Resource with Type='AWS::EC2::Instance'.