Skip to content

Commit 849b61f

Browse files
author
Sean Sundberg
authored
Uses new is_default flag for addresses_prefixes (#40)
* Updates ibm provider dependency to >= 1.25.0 to get is_default capability for address prefix * Uses new is_default flag for VPC addresses_prefixes * Removes unnecessary null_resource that previously set is_default via the cli Signed-off-by: Sean Sundberg <[email protected]>
1 parent 066b5d5 commit 849b61f

File tree

4 files changed

+9
-28
lines changed

4 files changed

+9
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The module depends on the following software components:
1919

2020
### Terraform providers
2121

22-
- IBM Cloud provider >= 1.22.0
22+
- IBM Cloud provider >= 1.25.0
2323

2424
## Module dependencies
2525

main.tf

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,11 @@ resource ibm_is_vpc_address_prefix cidr_prefix {
3939
zone = local.vpc_zone_names[count.index]
4040
vpc = data.ibm_is_vpc.vpc.id
4141
cidr = local.ipv4_cidr_block[count.index]
42-
}
43-
44-
# Set the address prefixes as the default. This will allow us to specify the number of ips required
45-
# in each subnet, instead of figuring out specific cidrs.
46-
# Note the "split" function call - this is because the id returned from creating the address
47-
# comes back as <vpc_id>/<address_range_id> and the update call wants these passed as separate
48-
# arguments. I suspect this is actually a defect in what is returned from ibm_is_vpc_address_prefix
49-
# and it may one day be fixed and trip up this code.
50-
resource null_resource post_vpc_address_pfx_default {
51-
count = local.provision_cidr ? 1 : 0
52-
depends_on = [ibm_is_vpc_address_prefix.cidr_prefix]
53-
54-
provisioner "local-exec" {
55-
command = <<COMMAND
56-
ibmcloud login --apikey ${var.ibmcloud_api_key} -r ${var.region} -g ${var.resource_group_name} --quiet ; \
57-
ibmcloud is vpc-address-prefix-update '${local.provision_cidr ? ibm_is_vpc.vpc[0].id : ""}' '${split("/", local.provision_cidr ? ibm_is_vpc_address_prefix.cidr_prefix[0].id : "/")[1]}' --default true ; \
58-
ibmcloud is vpc-address-prefix-update '${local.provision_cidr ? ibm_is_vpc.vpc[0].id : ""}' '${split("/", local.provision_cidr ? ibm_is_vpc_address_prefix.cidr_prefix[1].id : "/")[1]}' --default true ; \
59-
ibmcloud is vpc-address-prefix-update '${local.provision_cidr ? ibm_is_vpc.vpc[0].id : ""}' '${split("/", local.provision_cidr ? ibm_is_vpc_address_prefix.cidr_prefix[2].id : "/")[1]}' --default true ; \
60-
COMMAND
61-
}
42+
is_default = count.index < local.zone_count
6243
}
6344

6445
resource null_resource setup_default_acl {
65-
depends_on = [null_resource.post_vpc_address_pfx_default]
46+
depends_on = [ibm_is_vpc.vpc]
6647
count = var.provision ? 1 : 0
6748

6849
provisioner "local-exec" {

outputs.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
output "name" {
33
value = local.vpc_name
4-
depends_on = [null_resource.post_vpc_address_pfx_default, ibm_is_vpc.vpc]
4+
depends_on = [ibm_is_vpc_address_prefix.cidr_prefix, ibm_is_vpc.vpc]
55
description = "The name of the vpc instance"
66
}
77

88
output "id" {
99
value = local.vpc_id
10-
depends_on = [null_resource.post_vpc_address_pfx_default, ibm_is_vpc.vpc]
10+
depends_on = [ibm_is_vpc_address_prefix.cidr_prefix, ibm_is_vpc.vpc]
1111
description = "The id of the vpc instance"
1212
}
1313

@@ -18,7 +18,7 @@ output "acl_id" {
1818

1919
output "crn" {
2020
value = local.crn
21-
depends_on = [null_resource.post_vpc_address_pfx_default, ibm_is_vpc.vpc]
21+
depends_on = [ibm_is_vpc_address_prefix.cidr_prefix, ibm_is_vpc.vpc]
2222
description = "The CRN for the vpc instance"
2323
}
2424

@@ -29,13 +29,13 @@ output "count" {
2929

3030
output "names" {
3131
value = [local.vpc_name]
32-
depends_on = [null_resource.post_vpc_address_pfx_default, ibm_is_vpc.vpc]
32+
depends_on = [ibm_is_vpc_address_prefix.cidr_prefix, ibm_is_vpc.vpc]
3333
description = "The name of the vpc instance"
3434
}
3535

3636
output "ids" {
3737
value = [local.vpc_id]
38-
depends_on = [null_resource.post_vpc_address_pfx_default, ibm_is_vpc.vpc]
38+
depends_on = [ibm_is_vpc_address_prefix.cidr_prefix, ibm_is_vpc.vpc]
3939
description = "The id of the vpc instance"
4040
}
4141

version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
ibm = {
66
source = "ibm-cloud/ibm"
7-
version = ">= 1.22.0"
7+
version = ">= 1.25.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)