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

determanistic subnet cidr calculation #136

Open
ivan-aws opened this issue Oct 30, 2023 · 3 comments
Open

determanistic subnet cidr calculation #136

ivan-aws opened this issue Oct 30, 2023 · 3 comments

Comments

@ivan-aws
Copy link

when updating the az_count, i noticed that not all subnet cidr range calculations are deterministic. after changing the value from 1 to 2, for one of the subnets terraform triggered a replacement, as the cidr range changed:

      ~ cidr_block                                     = "10.32.0.64/28" -> "10.32.0.128/28" # forces replacement

this is less than ideal, as there are already network interfaces deployed into the subnet

@drewmullen
Copy link
Contributor

Hi! Thanks for opening this issue and for your feedback!

We are aware of this situation and documented a fix. https://github.com/aws-ia/terraform-aws-vpc#updating-a-vpc-with-new-or-removed-subnets

Atm there are not great functions for cidr calculation that can prevent this. Although custom provider functions could help in the future.

Hope this helps. If you have other feedback please let us know!

@bobdoah
Copy link

bobdoah commented Feb 12, 2024

I'm using IPAM, so the cidr_blocks aren't known in advance. The suggested fix won't work in this scenario.

@drewmullen
Copy link
Contributor

drewmullen commented Feb 12, 2024

For ipam You can request specific cidrs from ipam. It will work the same way as mentioned above just also reference the ipam pool id

I plan to perform a major update to this module once the ipam subnet values are added to the provider: hashicorp/terraform-provider-aws#34615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants