Description:
This pull request addresses a bug with the secondary CIDR creation in the module. The create_vpc local is fairly complex, taking into account whether vpc_id is passed or not. When setting up a secondary CIDR, we pass in vpc_id from another resource that hasn't been built yet, leading to a race condition and application errors. To fix this, we can introduce a create_vpc variable and change local.create_vpc to use its value instead of vpc_id. This fix ensures secondary CIDR creation within the first Terraform apply.
Changes Made:
Updated the condition for creating a VPC to utilize a variable instead of relying on the VPC's ID.
Added the variable azs to enable the calculation of AZs outside the module. During testing, we encountered an issue with creating a secondary CIDR where local.private_per_az and local.azs would be unknown until after the apply. The problem lies in the calculation of local.azs within the module. By passing it as var.azs instead, we resolve this issue.
Defaulted az_count to 0 making it optional in the case we are already using azs.
Provided an example demonstrating how to implement this update in the secondary CIDR example.
Description: This pull request addresses a bug with the secondary CIDR creation in the module. The
create_vpc
local is fairly complex, taking into account whethervpc_id
is passed or not. When setting up a secondary CIDR, we pass invpc_id
from another resource that hasn't been built yet, leading to a race condition and application errors. To fix this, we can introduce acreate_vpc
variable and changelocal.create_vpc
to use its value instead ofvpc_id
. This fix ensures secondary CIDR creation within the first Terraform apply.Changes Made:
azs
to enable the calculation of AZs outside the module. During testing, we encountered an issue with creating a secondary CIDR wherelocal.private_per_az
andlocal.azs
would be unknown until after the apply. The problem lies in the calculation oflocal.azs
within the module. By passing it asvar.azs
instead, we resolve this issue.az_count
to 0 making it optional in the case we are already usingazs
.Related Issues: https://github.com/aws-ia/terraform-aws-vpc/issues/142