Skip to content

Commit

Permalink
aws: Don't add dependency on additional CIDR for shared VPC
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman committed Oct 3, 2023
1 parent ecda9e8 commit f26874c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions pkg/model/awsmodel/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,19 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error {

if subnetSpec.CIDR != "" {
subnet.CIDR = fi.PtrTo(subnetSpec.CIDR)
for _, cidr := range b.Cluster.Spec.Networking.AdditionalNetworkCIDRs {
_, additionalCIDR, err := net.ParseCIDR(cidr)
if err != nil {
return err
}
subnetIP, _, err := net.ParseCIDR(subnetSpec.CIDR)
if err != nil {
return err
}
if additionalCIDR.Contains(subnetIP) {
subnet.VPCCIDRBlock = &awstasks.VPCCIDRBlock{Name: fi.PtrTo(cidr)}
if !sharedVPC {
for _, cidr := range b.Cluster.Spec.Networking.AdditionalNetworkCIDRs {
_, additionalCIDR, err := net.ParseCIDR(cidr)
if err != nil {
return err
}
subnetIP, _, err := net.ParseCIDR(subnetSpec.CIDR)
if err != nil {
return err
}
if additionalCIDR.Contains(subnetIP) {
subnet.VPCCIDRBlock = &awstasks.VPCCIDRBlock{Name: fi.PtrTo(cidr)}
}
}
}
}
Expand Down

0 comments on commit f26874c

Please sign in to comment.