aws-cloudformation / cloudformation-cli

The CloudFormation Provider Development Toolkit allows you to author your own resource providers and modules that can be used by CloudFormation.
Apache License 2.0
318 stars 162 forks source link

Resource generation outstanding issues #118

Open johnttompkins opened 5 years ago

johnttompkins commented 5 years ago

The current resource generator in #104 handles simpler cases of resource generation. The below items are necessary to bring the generator to a more operable state that can handle most if not all valid resource definition schemas.

Also, some research needs to be done to see if the flattener and resource generator can be combined in some way. They are both walking the schema in a similar way, so it would be nice to remove duplicate implementations of this to lessen the amount of code to be maintained.

iann0036 commented 4 years ago

Relating to type is string / type keywords, here's the trace for when type is an array of simpleTypes:

[2019-12-09T03:35:45Z] DEBUG    - Unhandled exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/rpdk/core/cli.py", line 98, in main
    args.command(args)
  File "/usr/local/lib/python3.7/site-packages/rpdk/core/generate.py", line 15, in generate
    project.generate()
  File "/usr/local/lib/python3.7/site-packages/rpdk/core/project.py", line 243, in generate
    return self._plugin.generate(self)
  File "/usr/local/lib/python3.7/site-packages/rpdk/go/codegen.py", line 151, in generate
    contents = template.render(models=models)
  File "/usr/local/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.7/site-packages/rpdk/go/templates/types.go.tple", line 18, in top-level template code
    {{ name|uppercase_first_letter }} {{ type|translate_type }} `json:"{{ name }},omitempty"`
  File "/usr/local/lib/python3.7/site-packages/rpdk/go/resolver.py", line 16, in translate_type
    return PRIMITIVE_TYPES[resolved_type.type]
TypeError: unhashable type: 'list'
PatMyron commented 3 years ago

We should investigate https://pypi.org/project/hypothesis-jsonschema/


update: test resource generation itself was unfortunately mostly abandoned for years (until some regex work in https://github.com/aws-cloudformation/cloudformation-cli/pull/930, https://github.com/aws-cloudformation/cloudformation-cli/issues/939) in favor of developers providing hardcoded property values