-
Notifications
You must be signed in to change notification settings - Fork 437
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
issue with referencing ipv6 cidr block in subnet #3603
Labels
bug
Something isn't working
new
Un-triaged issue
pre-built providers
Issues around pre-built providers managed at https://github.com/hashicorp/cdktf-repository-manager
Comments
anilkaliya123
added
bug
Something isn't working
new
Un-triaged issue
pre-built providers
Issues around pre-built providers managed at https://github.com/hashicorp/cdktf-repository-manager
labels
Apr 23, 2024
anilkaliya123
changed the title
PROVIDER_NAME: short issue description
issue with referencing ipv6 cidr block in subnet
Apr 24, 2024
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
}
}
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
new
Un-triaged issue
pre-built providers
Issues around pre-built providers managed at https://github.com/hashicorp/cdktf-repository-manager
Expected Behavior
I am trying to create a vpc and subnet and assign amazon-provided ipv6 to vpc.
The second resource is subnet which uses the ipv6 cidr_block of vpc but has smaller subnet ("/64").
I assumed this should have worked, since subnet is dependent on vpc,
it should be able to read the ipv6 cidr block of vpc and truncate to /64.
class DbVpcStack(TerraformStack):
def init(
self,
scope: Construct,
stack_id: str,
region: str,
dbvpc_cidr_block: str,
):
super().init(scope, stack_id)
test_vpc = Vpc(
self,
"cmc-vpc",
cidr_block="10.10.0.0/16",
enable_dns_hostnames=True,
tags={**DEFAULT_TAGS, "Name": f"{stack_id}-test"},
assign_generated_ipv6_cidr_block=true
)
test_subnet = Subnet(
self,
"test-subnet-external",
tags={**DEFAULT_TAGS_CMC, "Name": f"{stack_id}-test-external"},
cidr_block="10.10.0.0/16",
availability_zone=REGION_AZ_MAPPING[region][0],
vpc_id=test_vpc.id,
map_public_ip_on_launch=False,
depends_on =[cmc_vpc],
ipv6_cidr_block = test_vpc.ipv6_cidr_block.split("/")[0] + "/64"
)
The text was updated successfully, but these errors were encountered: