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

All Module Outputs Typed as String #287

Open
skorfmann opened this issue Aug 6, 2020 · 5 comments
Open

All Module Outputs Typed as String #287

skorfmann opened this issue Aug 6, 2020 · 5 comments
Labels
bug/has-workaround A bug with a workaround (may not be elegant) bug Something isn't working help wanted Community contributions welcome as the core team is unlikely to work on this soon modules priority/backlog Low priority (though possibly still important). Unlikely to be worked on within the next 6 months.

Comments

@skorfmann
Copy link
Contributor

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

  • ALL

Affected Resource(s)

  • Modules

Debug Output

E.g the AWS VPC Module:

public get publicSubnetsOutput(): string {
    return this.interpolationForOutput('public_subnets')
  }

Expected Behavior

This should be treated as list of strings

Actual Behavior

It's treated as simple string

Steps to Reproduce

Import VPC module and reference the output

@skorfmann skorfmann added bug Something isn't working modules labels Aug 6, 2020
@skorfmann skorfmann changed the title Module Outputs Typed as String All Module Outputs Typed as String Aug 6, 2020
@skorfmann skorfmann mentioned this issue Jan 26, 2021
8 tasks
@orendain
Copy link

orendain commented Sep 28, 2021

In the meantime, are there workarounds that are expected to work?

@jsteinich wrote in #606:

You could try using Token.asList on the module output to workaround.

In my case, I have an output that should be recognized as an object w/ a couple of attributes. I'm struggling to have it recognized as such. Using Token().as_any will still result in AttributeError: '<class 'cdktf._IResolvableProxy'>' object has no attribute 'my_attribute' when synthesizing.

@jsteinich
Copy link
Collaborator

In my case, I have an output that should be recognized as an object w/ a couple of attributes. I'm struggling to have it recognized as such. Using Token().as_any will still result in AttributeError: '<class 'cdktf._IResolvableProxy'>' object has no attribute 'my_attribute' when synthesizing.

You could manually construct hcl and use escape hatches, but probably easier to try to use Fn.lookup. Should just be able to pass the output directly, the name of the attribute, and a default value to the function.

@xiehan xiehan added the bug/has-workaround A bug with a workaround (may not be elegant) label Nov 22, 2022
@c0deaddict
Copy link

c0deaddict commented Dec 30, 2022

I also encounter this bug using Python with the CDKTF and the VPC module. Is there any known workaround for Python? I tried typing.cast(list[str], self.vpc.private_subnet_outputs) but that doesn't change anything.

Update Found it! Token.as_list(self.vpc.private_subnet_outputs) seems to work

@xiehan xiehan added help wanted Community contributions welcome as the core team is unlikely to work on this soon priority/backlog Low priority (though possibly still important). Unlikely to be worked on within the next 6 months. labels Jun 1, 2023
@josh-thisisbud
Copy link

This sort of thing needs to be documented.

@starbuggx
Copy link

Token.as_list is working with a list from _output, but when I tried to get a target group arn from target_groups_output, the original output is string, but after I tried Token.as_list, Token.as_string_map(dict), I still cannot get the arn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/has-workaround A bug with a workaround (may not be elegant) bug Something isn't working help wanted Community contributions welcome as the core team is unlikely to work on this soon modules priority/backlog Low priority (though possibly still important). Unlikely to be worked on within the next 6 months.
Projects
None yet
Development

No branches or pull requests

7 participants