Skip to content

Commit

Permalink
added forcenew for address_prefix_management in ibm_is_vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
uibm authored and hkantare committed Sep 2, 2021
1 parent 0608320 commit 583131c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 23 deletions.
12 changes: 6 additions & 6 deletions ibm/resource_ibm_is_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ func resourceIBMISVPC() *schema.Resource {

Schema: map[string]*schema.Schema{
isVPCAddressPrefixManagement: {
Type: schema.TypeString,
Optional: true,
Default: "auto",
DiffSuppressFunc: applyOnce,
ValidateFunc: InvokeValidator("ibm_is_vpc", isVPCAddressPrefixManagement),
Description: "Address Prefix management value",
Type: schema.TypeString,
Optional: true,
Default: "auto",
ForceNew: true,
ValidateFunc: InvokeValidator("ibm_is_vpc", isVPCAddressPrefixManagement),
Description: "Address Prefix management value",
},

isVPCDefaultNetworkACL: {
Expand Down
74 changes: 58 additions & 16 deletions ibm/resource_ibm_is_vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,41 @@ func TestAccIBMISVPC_basic(t *testing.T) {
})
}

func TestAccIBMISVPC_basic_apm(t *testing.T) {
var vpc string
name := fmt.Sprintf("terraformvpcuat-%d", acctest.RandIntRange(10, 100))
apm1 := "auto"
apm2 := "manual"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckIBMISVPCDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMISVPCConfig2(name, apm1),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMISVPCExists("ibm_is_vpc.testacc_vpc1", vpc),
resource.TestCheckResourceAttr(
"ibm_is_vpc.testacc_vpc1", "name", name),
resource.TestCheckResourceAttr(
"ibm_is_vpc.testacc_vpc1", "address_prefix_management", apm1),
),
},
{
Config: testAccCheckIBMISVPCConfig2(name, apm2),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMISVPCExists("ibm_is_vpc.testacc_vpc1", vpc),
resource.TestCheckResourceAttr(
"ibm_is_vpc.testacc_vpc1", "name", name),
resource.TestCheckResourceAttr(
"ibm_is_vpc.testacc_vpc1", "address_prefix_management", apm2),
),
},
},
})
}

func TestAccIBMISVPC_securityGroups(t *testing.T) {
var vpc string
vpcname := fmt.Sprintf("terraformvpcuat-%d", acctest.RandIntRange(10, 100))
Expand Down Expand Up @@ -137,34 +172,41 @@ func testAccCheckIBMISVPCExists(n, vpcID string) resource.TestCheckFunc {

func testAccCheckIBMISVPCConfig(name string) string {
return fmt.Sprintf(`
resource "ibm_is_vpc" "testacc_vpc" {
name = "%s"
default_network_acl_name = "dnwacln"
default_security_group_name = "dsgn"
default_routing_table_name = "drtn"
tags = ["Tag1", "tag2"]
}`, name)
resource "ibm_is_vpc" "testacc_vpc" {
name = "%s"
default_network_acl_name = "dnwacln"
default_security_group_name = "dsgn"
default_routing_table_name = "drtn"
tags = ["Tag1", "tag2"]
}`, name)

}

func testAccCheckIBMISVPCConfigUpdate(name string) string {
return fmt.Sprintf(`
resource "ibm_is_vpc" "testacc_vpc" {
name = "%s"
tags = ["tag1"]
}`, name)
resource "ibm_is_vpc" "testacc_vpc" {
name = "%s"
tags = ["tag1"]
}`, name)

}

func testAccCheckIBMISVPCConfig1(name string, apm string) string {
return fmt.Sprintf(`
resource "ibm_is_vpc" "testacc_vpc1" {
name = "%s"
address_prefix_management = "%s"
tags = ["Tag1", "tag2"]
}`, name, apm)
resource "ibm_is_vpc" "testacc_vpc1" {
name = "%s"
address_prefix_management = "%s"
tags = ["Tag1", "tag2"]
}`, name, apm)

}
func testAccCheckIBMISVPCConfig2(name string, apm string) string {
return fmt.Sprintf(`
resource "ibm_is_vpc" "testacc_vpc1" {
name = "%s"
address_prefix_management = "%s"
}`, name, apm)
}

func testAccCheckIBMISVPCSgConfig(vpcname string, sgname string) string {
return fmt.Sprintf(`
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/is_vpc.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The `ibm_is_vpc` resource provides the following [[Timeouts](https://www.terrafo
## Argument reference
Review the argument references that you can specify for your resource.

- `address_prefix_management` - (Optional, String) Indicates whether a default address prefix should be created automatically `auto` or manually `manual` for each zone in this VPC. Default value is `auto`.
- `address_prefix_management` - (Optional, Forces new resource, String) Indicates whether a default address prefix should be created automatically `auto` or manually `manual` for each zone in this VPC. Default value is `auto`.
- `classic_access` - (Optional, Bool) Specify if you want to create a VPC that can connect to classic infrastructure resources. Enter **true** to set up private network connectivity from your VPC to classic infrastructure resources that are created in the same IBM Cloud account, and **false** to disable this access. If you choose to not set up this access, you cannot enable it after the VPC is created. Make sure to review the [prerequisites](https://cloud.ibm.com/docs/vpc-on-classic-network?topic=vpc-on-classic-setting-up-access-to-your-classic-infrastructure-from-vpc#vpc-prerequisites) before you create a VPC with classic infrastructure access. Note that you can enable one VPC for classic infrastructure access per IBM Cloud account only.
- `default_network_acl`- (Deprecated, String) The ID of the default network ACL.
- `default_network_acl_name` - (Optional, String) Enter the name of the default network access control list (ACL).
Expand Down

0 comments on commit 583131c

Please sign in to comment.