File tree Expand file tree Collapse file tree 5 files changed +19
-12
lines changed Expand file tree Collapse file tree 5 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,23 @@ locals {
1717 vpc = try (var. enabled ? data. ibm_is_vpc . vpc [0 ] : tomap (false ), {})
1818}
1919
20+ resource null_resource print_names {
21+ provisioner "local-exec" {
22+ command = " echo 'Resource group: ${ var . resource_group_name } '"
23+ }
24+ }
25+
26+ data ibm_resource_group resource_group {
27+ depends_on = [null_resource. print_names ]
28+
29+ name = var. resource_group_name
30+ }
31+
2032resource ibm_is_vpc vpc {
2133 count = var. provision && var. enabled ? 1 : 0
2234
2335 name = local. vpc_name
24- resource_group = var . resource_group_id
36+ resource_group = data . ibm_resource_group . resource_group . id
2537 address_prefix_management = local. ipv4_cidr_provided ? " manual" : " auto"
2638 default_security_group_name = " ${ local . vpc_name } -default"
2739 default_network_acl_name = " ${ local . vpc_name } -default"
@@ -120,7 +132,7 @@ resource ibm_is_security_group base {
120132
121133 name = local. base_security_group_name
122134 vpc = lookup (local. vpc , " id" , " " )
123- resource_group = var . resource_group_id
135+ resource_group = data . ibm_resource_group . resource_group . id
124136}
125137
126138data ibm_is_security_group base {
Original file line number Diff line number Diff line change @@ -17,10 +17,6 @@ versions:
1717 - source : github.com/cloud-native-toolkit/terraform-ibm-resource-group
1818 version : " >= 2.1.0"
1919 variables :
20- - name : resource_group_id
21- moduleRef :
22- id : resource_group
23- output : id
2420 - name : resource_group_name
2521 moduleRef :
2622 id : resource_group
Original file line number Diff line number Diff line change @@ -48,3 +48,8 @@ output "addresses" {
4848 value = [for obj in lookup (local. vpc , " cse_source_addresses[*]" , []): obj . address ]
4949 description = " The ip address ranges for the VPC"
5050}
51+
52+ output "enabled" {
53+ value = var. enabled
54+ description = " Flag indicating that the module will provision resources"
55+ }
Original file line number Diff line number Diff line change 11module "dev_vpc" {
22 source = " ./module"
33
4- resource_group_id = module. resource_group . id
54 resource_group_name = module. resource_group . name
65 region = var. region
76 name_prefix = var. name_prefix
Original file line number Diff line number Diff line change 11# Resource Group Variables
2- variable "resource_group_id" {
3- type = string
4- description = " The id of the IBM Cloud resource group where the VPC instance will be created."
5- }
6-
72variable "resource_group_name" {
83 type = string
94 description = " The name of the IBM Cloud resource group where the VPC instance will be created."
You can’t perform that action at this time.
0 commit comments