Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added forcenew for address_prefix_management in ibm_is_vpc #3025

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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