Skip to content

Commit

Permalink
fix: fixed bug which was causing re-apply to fail when using secondar…
Browse files Browse the repository at this point in the history
…y subnets and security groups (terraform-ibm-modules#557)
  • Loading branch information
jor2 committed Oct 10, 2023
1 parent 2af91de commit ba4d31d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ output "slz_vsi" {
value = module.slz_vsi
description = "VSI module values"
}

output "secondary_subnets" {
description = "Secondary subnets created"
value = local.secondary_subnet_zone_list
}

output "secondary_security_groups" {
description = "Secondary security groups created"
value = local.secondary_security_groups
}
10 changes: 9 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,15 @@ resource "ibm_is_instance" "vsi" {
}
content {
subnet = network_interfaces.value.id
security_groups = flatten([
# If security_groups is empty(list is len(0)) then default list to default_security_group_id.
# If list is empty it will fail on reapply as when vsi is passed an empty security group list it will attach the default security group.
security_groups = length(flatten([
(var.create_security_group && var.secondary_use_vsi_security_group ? [ibm_is_security_group.security_group[var.security_group.name].id] : []),
[
for group in var.secondary_security_groups :
group.security_group_id if group.interface_name == network_interfaces.value.name
]
])) == 0 ? [local.default_security_group_id] : flatten([
(var.create_security_group && var.secondary_use_vsi_security_group ? [ibm_is_security_group.security_group[var.security_group.name].id] : []),
[
for group in var.secondary_security_groups :
Expand Down
4 changes: 2 additions & 2 deletions module-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
},
"pos": {
"filename": "main.tf",
"line": 174
"line": 182
}
},
"ibm_is_floating_ip.vsi_fip": {
Expand All @@ -485,7 +485,7 @@
},
"pos": {
"filename": "main.tf",
"line": 166
"line": 174
}
},
"ibm_is_instance.vsi": {
Expand Down

0 comments on commit ba4d31d

Please sign in to comment.