Exception: Failed to render argument stack_name with value:
dunnmj42 opened this issue · comments
Second error I'm running into is a new one.
Exception: Failed to render argument stack_name with value: template
"template" in this case is just the name of the YAML template file I am starting from.
I confirmed this by renaming the template and re-running the tool.
Here is the full Traceback:
Traceback (most recent call last):
File "/Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/terraform/hcl2/_block.py", line 100, in render_arguments
results.append(f"{indent_spacing}{name} = {value.render(indent)}")
AttributeError: 'str' object has no attribute 'render'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/***/Library/Python/3.9/bin/cf2tf", line 8, in <module>
sys.exit(cli())
File "/Users/***/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Users/***/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/***/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/***/Library/Python/3.9/lib/python/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/app.py", line 47, in cli
config.save(output_writer)
File "/Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/terraform/_configuration.py", line 18, in save
output.save(self.resources)
File "/Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/save.py", line 85, in save
raise e
File "/Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/save.py", line 82, in save
print(resource)
File "/Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/terraform/hcl2/_block.py", line 50, in __str__
return self.render()
File "/Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/terraform/hcl2/_block.py", line 76, in render
block_args = render_arguments(self.arguments, indent)
File "/Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/terraform/hcl2/_block.py", line 104, in render_arguments
raise Exception(
Exception: Failed to render argument stack_name with value:
template
Hopefully this will mean more to you than it does to me. I am only loosely familiar with both CF and TF (and Python for that matter) but this seems to be expecting an object instead of a string here, but seems to be getting that value just from the filename.
I actually independently ran into this issue on my own while troubleshooting another issue. Yes its a bug and I have it fixed locally. Give me a day or two to get it pushed up and released.
But if you want to patch it locally, Go to this file /Users/***/Library/Python/3.9/lib/python/site-packages/cf2tf/conversion/expressions.py
Find this local_block.arguments["stack_name"] = template.name
Then change it to local_block.arguments["stack_name"] = StringType(template.name)
It's likely if you patch that ^ you will get the converted terraform. because you already went through the conversion and now you are just writing the files out.