Skip to content

Commit

Permalink
azurerm_express_route_gateway - prevent panic (#26467)
Browse files Browse the repository at this point in the history
* azurerm_express_route_gateway - prevent crash

* do it right

* Update internal/services/network/express_route_gateway_resource.go

Co-authored-by: Matthew Frahry <mbfrahry@gmail.com>

* Update internal/services/network/express_route_gateway_resource.go

Co-authored-by: Matthew Frahry <mbfrahry@gmail.com>

* Update internal/services/network/express_route_gateway_resource.go

Co-authored-by: Matthew Frahry <mbfrahry@gmail.com>

* Update internal/services/network/express_route_gateway_resource.go

Co-authored-by: Matthew Frahry <mbfrahry@gmail.com>

---------

Co-authored-by: Matthew Frahry <mbfrahry@gmail.com>
  • Loading branch information
katbyte and mbfrahry authored Jun 28, 2024
1 parent 4618dfa commit 69c8503
Showing 1 changed file with 46 additions and 23 deletions.
69 changes: 46 additions & 23 deletions internal/services/network/express_route_gateway_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,31 +285,54 @@ func convertConnectionsToGatewayConnections(input *[]expressrouteconnections.Exp
},
ExpressRouteGatewayBypass: props.ExpressRouteGatewayBypass,
ProvisioningState: (*expressroutegateways.ProvisioningState)(props.ProvisioningState),
RoutingConfiguration: &expressroutegateways.RoutingConfiguration{
AssociatedRouteTable: &expressroutegateways.SubResource{
Id: props.RoutingConfiguration.AssociatedRouteTable.Id,
},
InboundRouteMap: &expressroutegateways.SubResource{
Id: props.RoutingConfiguration.InboundRouteMap.Id,
},
OutboundRouteMap: &expressroutegateways.SubResource{
Id: props.RoutingConfiguration.OutboundRouteMap.Id,
},
PropagatedRouteTables: &expressroutegateways.PropagatedRouteTable{
RoutingWeight: props.RoutingWeight,
}

if routingConfiguration := props.RoutingConfiguration; routingConfiguration != nil {
rc := &expressroutegateways.RoutingConfiguration{}

if routingConfiguration.AssociatedRouteTable != nil {
rc.AssociatedRouteTable = &expressroutegateways.SubResource{
Id: routingConfiguration.AssociatedRouteTable.Id,
}
}

if routingConfiguration.InboundRouteMap != nil {
rc.InboundRouteMap = &expressroutegateways.SubResource{
Id: routingConfiguration.InboundRouteMap.Id,
}
}

if routingConfiguration.OutboundRouteMap != nil {
rc.OutboundRouteMap = &expressroutegateways.SubResource{
Id: routingConfiguration.OutboundRouteMap.Id,
}
}

if routingConfiguration.PropagatedRouteTables != nil {
rc.PropagatedRouteTables = &expressroutegateways.PropagatedRouteTable{
Ids: convertConnectionsSubresourceToGatewaySubResource(props.RoutingConfiguration.PropagatedRouteTables.Ids),
Labels: props.RoutingConfiguration.PropagatedRouteTables.Labels,
},
VnetRoutes: &expressroutegateways.VnetRoute{
BgpConnections: convertConnectionsSubresourceToGatewaySubResource(props.RoutingConfiguration.VnetRoutes.BgpConnections),
StaticRoutes: convertConnectionsStaticRouteToGatewayStaticRoute(props.RoutingConfiguration.VnetRoutes.StaticRoutes),
StaticRoutesConfig: &expressroutegateways.StaticRoutesConfig{
PropagateStaticRoutes: i.Properties.RoutingConfiguration.VnetRoutes.StaticRoutesConfig.PropagateStaticRoutes,
VnetLocalRouteOverrideCriteria: (*expressroutegateways.VnetLocalRouteOverrideCriteria)(i.Properties.RoutingConfiguration.VnetRoutes.StaticRoutesConfig.VnetLocalRouteOverrideCriteria),
},
},
},
RoutingWeight: props.RoutingWeight,
Labels: routingConfiguration.PropagatedRouteTables.Labels,
}
}

if vnet := routingConfiguration.VnetRoutes; vnet != nil {
rc.VnetRoutes = &expressroutegateways.VnetRoute{
BgpConnections: convertConnectionsSubresourceToGatewaySubResource(vnet.BgpConnections),
StaticRoutes: convertConnectionsStaticRouteToGatewayStaticRoute(vnet.StaticRoutes),
}

if src := vnet.StaticRoutesConfig; src != nil {
rc.VnetRoutes.StaticRoutesConfig = &expressroutegateways.StaticRoutesConfig{
PropagateStaticRoutes: src.PropagateStaticRoutes,
VnetLocalRouteOverrideCriteria: (*expressroutegateways.VnetLocalRouteOverrideCriteria)(src.VnetLocalRouteOverrideCriteria),
}
}
}

o.Properties.RoutingConfiguration = rc
}

}
output = append(output, o)
}
Expand Down

0 comments on commit 69c8503

Please sign in to comment.