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

cdktf sourced modules are unable to use list type variables sourced from another module's output #606

Closed
celliott opened this issue Mar 19, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@celliott
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

cdktf & Language Versions

using typescript@4.2.3 and cdktf 0.2.0

Affected Resource(s)

cdktf importing of custom modules

Debug Output

https://gist.github.com/celliott/8fc7c7387ca2542ea7d50eebfe9d33c7

Expected Behavior

cdktf is able to generate working tf json for a module that uses type list variable source from another module's output

Actual Behavior

See gist for more detail

When I use a custom module that sources a list value from another module's output, tsc fails to compile with a type error. I see that custom sourced modules output types are always strings b/c they are references and not actual values.

  • The custom module wrapper generated by cdktf typed the input as string[]; which matches the module
  • The value sourced from the other module is a returned as a reference "${module.vpc.private_subnets_ids}". It is a string; not the actual value or string[]
  • Alternatively, if I change the ts to pass an array, then it uses ["${module.vpc.private_subnets_ids}"]. tsc is happy but TF correctly reads that as a nested array; which causes the error.

Steps to Reproduce

See gist for more detail

  • Add two sourced custom modules to cdktf.json
    • One must include an output with an array for a value
    • The other must use that value as an input typed list(string)
  • Create a basic cdktf definition with both modules. One using the list output as an input
  • $ cdktf get to generate the module wrappers
  • $ tsc <- where I see error 1

Important Factoids

  • Our modules are private or I would share a working example. If this bug is too confusing, then push back and I will create an example
  • I haven't tested yet, but I am planning on using a data source lookup to get the vpc values to pass to the rds module to route around this issue
@celliott celliott added the bug Something isn't working label Mar 19, 2021
@jsteinich
Copy link
Collaborator

Looks like a duplicate of #287.
You could try using Token.asList on the module output to workaround.

@celliott
Copy link
Author

closing as dupe of #287

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants