Skip to content
Open
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
11 changes: 11 additions & 0 deletions cloudstack/resource_cloudstack_private_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func resourceCloudStackPrivateGateway() *schema.Resource {
Required: true,
ForceNew: true,
},

"bypass_vlan_overlap_check": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
}
}
Expand Down Expand Up @@ -119,6 +125,11 @@ func resourceCloudStackPrivateGatewayCreate(d *schema.ResourceData, meta interfa
p.SetAclid(aclid.(string))
}

// Set bypass_vlan_overlap_check if specified
if bypassVlanOverlapCheck, ok := d.GetOk("bypass_vlan_overlap_check"); ok {
p.SetBypassvlanoverlapcheck(bypassVlanOverlapCheck.(bool))
}

// Create the new private gateway
r, err := cs.VPC.CreatePrivateGateway(p)
if err != nil {
Expand Down
74 changes: 71 additions & 3 deletions cloudstack/resource_cloudstack_private_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,52 @@ func TestAccCloudStackPrivateGateway_import(t *testing.T) {
},

{
ResourceName: "cloudstack_private_gateway.foo",
ImportState: true,
ImportStateVerify: true,
ResourceName: "cloudstack_private_gateway.foo",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"bypass_vlan_overlap_check"},
},
},
})
}

func TestAccCloudStackPrivateGateway_bypassVlanOverlapCheck(t *testing.T) {
var gateway cloudstack.PrivateGateway

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudStackPrivateGatewayDestroy,
Steps: []resource.TestStep{
{
Config: testAccCloudStackPrivateGateway_bypassVlanOverlapCheck,
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudStackPrivateGatewayExists(
"cloudstack_private_gateway.bar", &gateway),
resource.TestCheckResourceAttr(
"cloudstack_private_gateway.bar", "bypass_vlan_overlap_check", "true"),
),
},
},
})
}

func TestAccCloudStackPrivateGateway_bypassVlanOverlapCheckDefault(t *testing.T) {
var gateway cloudstack.PrivateGateway

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudStackPrivateGatewayDestroy,
Steps: []resource.TestStep{
{
Config: testAccCloudStackPrivateGateway_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudStackPrivateGatewayExists(
"cloudstack_private_gateway.foo", &gateway),
resource.TestCheckResourceAttr(
"cloudstack_private_gateway.foo", "bypass_vlan_overlap_check", "false"),
),
},
},
})
Expand Down Expand Up @@ -160,3 +203,28 @@ resource "cloudstack_private_gateway" "foo" {
acl_id = cloudstack_network_acl.foo.id
depends_on = ["cloudstack_vpc.foo","cloudstack_network_acl.foo"]
}`

const testAccCloudStackPrivateGateway_bypassVlanOverlapCheck = `
resource "cloudstack_vpc" "bar" {
name = "terraform-vpc-bypass"
cidr = "10.0.0.0/8"
vpc_offering = "Default VPC offering"
zone = "Sandbox-simulator"
}

resource "cloudstack_network_acl" "bar" {
name = "terraform-acl-bypass"
vpc_id = cloudstack_vpc.bar.id
depends_on = ["cloudstack_vpc.bar"]
}

resource "cloudstack_private_gateway" "bar" {
gateway = "10.1.1.254"
ip_address = "192.168.0.2"
netmask = "255.255.255.0"
vlan = "2"
vpc_id = cloudstack_vpc.bar.id
acl_id = cloudstack_network_acl.bar.id
bypass_vlan_overlap_check = true
depends_on = ["cloudstack_vpc.bar","cloudstack_network_acl.bar"]
}`
19 changes: 19 additions & 0 deletions website/docs/r/private_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ resource "cloudstack_private_gateway" "default" {
}
```

Example with VLAN overlap check bypass:

```hcl
resource "cloudstack_private_gateway" "with_bypass" {
gateway = "10.0.0.1"
ip_address = "10.0.0.2"
netmask = "255.255.255.252"
vlan = "200"
vpc_id = "76f6e8dc-07e3-4971-b2a2-8831b0cc4cb4"
acl_id = "cf4f1dad-aade-4ccd-866c-0a2166e5be3d"
bypass_vlan_overlap_check = true
}
```

## Argument Reference

The following arguments are supported:
Expand All @@ -51,6 +65,11 @@ The following arguments are supported:
* `vpc_id` - (Required) The VPC ID in which to create this Private gateway. Changing
this forces a new resource to be created.

* `bypass_vlan_overlap_check` - (Optional) When set to true, bypasses the VLAN overlap
check during private gateway creation. This allows creating private gateways with
VLANs that may overlap with existing VLANs in the physical network. Defaults to
false.

## Attributes Reference

The following attributes are exported:
Expand Down
Loading