terraform-cdk
terraform-cdk copied to clipboard
Convert: variables are referenced incorrectly
trafficstars
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
Affected Resource(s)
Description
A converted variable can be of any type possibly lack type information at all. Each variable is used in the converted code through myVar.value (I think value is even dropped if a property access happens). They should be used according to the type they have and either access through stringValue, numberValue or Token.asStringMap(myVar.value) etc.
Example
Convert this:
variable "default_tags" {
type = map(string)
description = "Map of default tags to apply to resources"
default = {
project = "Learning Live with AWS & HashiCorp"
}
}
resource "aws_eip" "nat" {
vpc = true
tags = {
"Name" = "${var.default_tags.project}-nat-eip"
}
}
References
- #0000