Open skorfmann opened 4 years ago
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.
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 inAttributeError: '<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.
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
This sort of thing needs to be documented.
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.
Community Note
cdktf & Language Versions
Affected Resource(s)
Debug Output
E.g the AWS VPC Module:
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