Skip to content

Commit

Permalink
fix: add idempotency for vpc route add
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
  • Loading branch information
prb112 committed Oct 23, 2023
1 parent a7f2065 commit 637ee87
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/1_vpc_prepare/routes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
# SPDX-License-Identifier: Apache-2.0
################################################################

data "ibm_is_vpc_routing_tables" "rts" {
vpc = data.ibm_is_vpc.vpc.id
}

locals {
rt_matches = [for rt in data.ibm_is_vpc_routing_tables.rts.routing_tables : rt if endswith(rt.name, "to-powervs-route-1")]
rt_exists = length(local.sg_matches) > 0 ? 0 : 1
}

resource "ibm_is_vpc_routing_table_route" "route_to_powervs" {
count = local.rt_exists
vpc = data.ibm_is_vpc.vpc.id
routing_table = data.ibm_is_vpc.vpc.default_routing_table
zone = data.ibm_is_vpc.vpc.subnets[0].zone
Expand Down

0 comments on commit 637ee87

Please sign in to comment.