Fix the detection and rendering of multiple additionalNetworkCIDR blocks

This commit is contained in:
Peter Rifel 2020-09-27 20:12:09 -05:00
parent 0978cd97e8
commit 4bcfebebcc
No known key found for this signature in database
GPG Key ID: BC6469E5B16DB2B6
4 changed files with 15 additions and 4 deletions

View File

@ -93,7 +93,7 @@ func (b *NetworkModelBuilder) Build(c *fi.ModelBuilderContext) error {
Lifecycle: b.Lifecycle,
VPC: b.LinkToVPC(),
Shared: fi.Bool(sharedVPC),
CIDRBlock: &cidr,
CIDRBlock: s(cidr),
})
}
}

View File

@ -931,7 +931,7 @@
"VpcId": {
"Ref": "AWSEC2VPCcomplexexamplecom"
},
"CidrBlock": "10.2.0.0/16"
"CidrBlock": "10.1.0.0/16"
}
},
"AWSEC2VPCCidrBlock1020016": {

View File

@ -732,7 +732,7 @@ resource "aws_vpc_dhcp_options" "complex-example-com" {
}
resource "aws_vpc_ipv4_cidr_block_association" "cidr-10-1-0-0--16" {
cidr_block = "10.2.0.0/16"
cidr_block = "10.1.0.0/16"
vpc_id = aws_vpc.complex-example-com.id
}

View File

@ -48,10 +48,21 @@ func (e *VPCCIDRBlock) Find(c *fi.Context) (*VPCCIDRBlock, error) {
return nil, err
}
found := false
for _, cba := range vpc.CidrBlockAssociationSet {
if fi.StringValue(cba.CidrBlock) == fi.StringValue(e.CIDRBlock) {
found = true
break
}
}
if !found {
return nil, nil
}
actual := &VPCCIDRBlock{
CIDRBlock: e.CIDRBlock,
VPC: &VPC{ID: vpc.VpcId},
}
actual.VPC = &VPC{ID: vpc.VpcId}
// Prevent spurious changes
actual.Shared = e.Shared