Open anilkaliya123 opened 2 months ago
Pythonic string manipulation only happens when you synthesize the stack. The ipv6 block is resolved on deploy. You need to use the objects that corresponds with hcl string manipulation, which is resolved on deploy:
from cdktf import StringConcat, FnGenerated
str_concat = StringConcat()
test_vpc = Vpc(self, "cmc-vpc", cidr_block="10.10.0.0/16", enable_dns_hostnames=True, assign_generated_ipv6_cidr_block=True)
test_subnet = Subnet(
self,
"test-subnet-external",
cidr_block="10.10.0.0/16",
vpc_id=test_vpc.id,
map_public_ip_on_launch=False,
ipv6_cidr_block=str_concat.join(FnGenerated.element(FnGenerated.split("/", test_vpc.ipv6_cidr_block), 0), "/64"),
)
Converted into JSON:
"resource": {
"aws_subnet": {
"test-subnet-external": {
"//": {
"metadata": {
"path": "example/test-subnet-external",
"uniqueId": "test-subnet-external"
}
},
"cidr_block": "10.10.0.0/16",
"ipv6_cidr_block": "${element(split(\"/\", aws_vpc.cmc-vpc.ipv6_cidr_block), 0)}/64",
"map_public_ip_on_launch": false,
"vpc_id": "${aws_vpc.cmc-vpc.id}"
}
},
"aws_vpc": {
"cmc-vpc": {
"//": {
"metadata": {
"path": "example/cmc-vpc",
"uniqueId": "cmc-vpc"
}
},
"assign_generated_ipv6_cidr_block": true,
"cidr_block": "10.10.0.0/16",
"enable_dns_hostnames": true
}
}
},
Expected Behavior
it should be able to read the ipv6 cidr block of vpc and truncate to /64.
Actual Behavior
Steps to Reproduce