Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SAM resource types like AWS::Serverless::Function #99

Open
praveenrengarajan opened this issue Dec 7, 2022 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@praveenrengarajan
Copy link

https://github.com/awslabs/aws-api-gateway-developer-portal/blob/main/cloudformation/template.yaml

// Converting aws_cf_template.yaml to Terraform!
[####--------------------------------] 12% 00:03:03 code has been checked out.
Traceback (most recent call last):
File "c:\users\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\appdata\local\programs\python\python37\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\AppData\Local\Programs\Python\Python37\Scripts\cf2tf.exe_main
.py", line 9, in
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1130, in call
return self.main(*args, **kwargs)
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\cf2tf\app.py", line 44, in cli
config = TemplateConverter(tmpl_path.stem, cf_template, search_manger).convert()
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\cf2tf\convert.py", line 94, in convert
tf_resources = self.convert_to_tf(self.manifest)
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\cf2tf\convert.py", line 146, in convert_to_tf
tf_resources.extend(converter(resources))
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\cf2tf\convert.py", line 332, in convert_resources
properties, functions.ALL_FUNCTIONS
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\cf2tf\convert.py", line 182, in resolve_values
value, allowed_func, prev_func, inside_function=inside_function
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\cf2tf\convert.py", line 193, in resolve_values
return allowed_func[key](self, value)
File "c:\users\appdata\local\programs\python\python37\lib\site-packages\cf2tf\conversion\expressions.py", line 422, in get_att

@shadycuz
Copy link
Member

I think I started on this back in December but was distracted by the holidays. I'm taking a fresh look at this now and I have identified the issue.

When I turn on debug logging I see:

debug: Converting the intrinsic functions to Terraform expressions...
debug: Fn::GetAtt - Looking up resource "CatalogUpdaterLambdaFunction"
debug: Converted CF type AWS::Serverless::Function to search term serverless function.
debug: Searcing for serverless function in terraform docs...
debug: Best match was lambda function event invoke config at /tmp/terraform_src/website/docs/r/lambda_function_event_invoke_config.html.markdown with score of 86.

Which basically means the program converted AWS::Serverless::Function to aws_lambda_function_event_invoke_config. I'm not sure why it ranked aws_lambda_function_event_invoke_config higher than aws_lambda_function but that is the bug.

I will see what I can do to fix this. My worry is that by changing the search algorithm it could break lots of other working stuff. There is a new "override" system that I recently released. I could use it to change AWS::Serverless::Function to AWS::Lambda::Function and that might also fix it in this case.

@shadycuz shadycuz added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed resource_search_error A CF resource was not correctly translated to Terraform labels Jun 18, 2023
@shadycuz
Copy link
Member

shadycuz commented Jul 8, 2023

I actually understand this a lot better now... AWS::Serverless::Function is part of SAM and is not supported yet. I think this is similar to #42 but not quite the same thing.

@shadycuz shadycuz changed the title Unable to convert Aws dev portal template Add support for SAM resource types like AWS::Serverless::Function Jul 8, 2023
@shadycuz shadycuz removed the resource_search_error A CF resource was not correctly translated to Terraform label Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants