Skip to content

Commit

Permalink
V11 Fix for issue #1117, #1102
Browse files Browse the repository at this point in the history
  • Loading branch information
VaishnaviGopal authored and hkantare committed Feb 25, 2020
1 parent 43faa83 commit bcb04c7
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 31 deletions.
19 changes: 14 additions & 5 deletions examples/ibm-is-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "ibm_is_vpc" "vpc1" {
name = "vpc1"
}

resource "ibm_is_vpc_route" {
resource "ibm_is_vpc_route" "route1" {
name = "route1"
vpc = "${ibm_is_vpc.vpc1.id}"
zone = "${var.zone1}"
Expand Down Expand Up @@ -47,7 +47,7 @@ resource "ibm_is_instance" "instance1" {
image = "${var.image}"
profile = "${var.profile}"

primary_network_interface = {
primary_network_interface {
port_speed = "1000"
subnet = "${ibm_is_subnet.subnet1.id}"
}
Expand Down Expand Up @@ -151,7 +151,7 @@ resource "ibm_is_instance" "instance2" {
image = "${var.image}"
profile = "${var.profile}"

primary_network_interface = {
primary_network_interface {
port_speed = "1000"
subnet = "${ibm_is_subnet.subnet2.id}"
}
Expand Down Expand Up @@ -217,33 +217,42 @@ resource "ibm_is_volume" "vol2" {
capacity = 200
}


resource "ibm_is_network_acl" "isExampleACL" {
name = "is-example-acl"

rules {
name = "outbound"
action = "allow"
source = "0.0.0.0/0"
destination = "0.0.0.0/0"
direction = "outbound"

tcp {
port_max = 65535
port_min = 1
source_port_max = 60000
source_port_min = 22
}
}

rules {
name = "inbound"
action = "allow"
source = "0.0.0.0/0"
destination = "0.0.0.0/0"
direction = "inbound"

tcp {
port_max = 65535
port_min = 1
source_port_max = 60000
source_port_min = 22
}
}
}
}

resource "ibm_is_public_gateway" "publicgateway1" {
name = "pg1"
vpc = "${ibm_is_vpc.vpc1.id}"
zone = "${var.zone1}"
}
6 changes: 2 additions & 4 deletions ibm/resource_ibm_is_networkacls.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func resourceIBMISNetworkACLUpdate(d *schema.ResourceData, meta interface{}) err
}
nwaclC := network.NewNetworkAclClient(sess)
nwaclid := d.Id()
rules := d.Get(isNetworkACLRules).([]interface{})
rules := d.Get(isNetworkACLRules).(*schema.Set).List()

if d.HasChange(isNetworkACLName) {
name := d.Get(isNetworkACLName).(string)
Expand Down Expand Up @@ -584,13 +584,11 @@ func createInlineRules(nwaclC *network.NetworkAclClient, nwaclid string, rules [
}
}

rule, err := nwaclC.AddRule(nwaclid, name, source, destination, direction, action, protocol,
_, err := nwaclC.AddRule(nwaclid, name, source, destination, direction, action, protocol,
int64(icmptype), int64(icmpcode), int64(minport), int64(maxport), int64(sourceminport), int64(sourcemaxport), before)
if err != nil {
return err
}

before = rule.ID.String()
}
return nil
}
Expand Down
17 changes: 16 additions & 1 deletion ibm/resource_ibm_is_public_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
isPublicGatewayVPC = "vpc"
isPublicGatewayZone = "zone"
isPublicGatewayFloatingIPAddress = "address"
isPublicGatewayResourceGroup = "resource_group"

isPublicGatewayProvisioning = "provisioning"
isPublicGatewayProvisioningDone = "available"
Expand Down Expand Up @@ -71,6 +72,13 @@ func resourceIBMISPublicGateway() *schema.Resource {
Computed: true,
},

isPublicGatewayResourceGroup: {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
},

isPublicGatewayVPC: {
Type: schema.TypeString,
ForceNew: true,
Expand Down Expand Up @@ -125,6 +133,10 @@ func resourceIBMISPublicGatewayCreate(d *schema.ResourceData, meta interface{})
name := d.Get(isPublicGatewayName).(string)
vpc := d.Get(isPublicGatewayVPC).(string)
zone := d.Get(isPublicGatewayZone).(string)
var rg string
if grp, ok := d.GetOk(isPublicGatewayResourceGroup); ok {
rg = grp.(string)
}
floatingipID := ""
floatingipadd := ""
if floatingipdataIntf, ok := d.GetOk(isPublicGatewayFloatingIP); ok {
Expand All @@ -140,7 +152,7 @@ func resourceIBMISPublicGatewayCreate(d *schema.ResourceData, meta interface{})
}

publicgwC := network.NewPublicGatewayClient(sess)
publicgw, err := publicgwC.Create(name, zone, vpc, floatingipID, floatingipadd)
publicgw, err := publicgwC.Create(name, zone, vpc, floatingipID, floatingipadd, rg)
if err != nil {
return err
}
Expand Down Expand Up @@ -217,6 +229,9 @@ func resourceIBMISPublicGatewayRead(d *schema.ResourceData, meta interface{}) er
d.Set(isPublicGatewayStatus, publicgw.Status)
d.Set(isPublicGatewayZone, publicgw.Zone.Name)
d.Set(isPublicGatewayVPC, publicgw.Vpc.ID.String())
if publicgw.ResourceGroup != nil {
d.Set(isPublicGatewayResourceGroup, publicgw.ResourceGroup.ID)
}

controller, err := getBaseController(meta)
if err != nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -1901,10 +1901,10 @@
"revisionTime": "2018-05-24T00:26:36Z"
},
{
"checksumSHA1": "YzFuV7mxbTPAcMJ6U6nW6acaFJo=",
"checksumSHA1": "op5FLKoRmF0/6ORi9d3q9aoYOJQ=",
"path": "github.ibm.com/Bluemix/riaas-go-client",
"revision": "44af28b491d11609c5708520ef64c69b25cbf11a",
"revisionTime": "2020-02-07T09:17:59Z",
"revision": "e1cef421a27ee39275b81bffce4ef0f5229cfbb1",
"revisionTime": "2020-02-20T12:34:19Z",
"tree": true
},
{
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/is_network_acl.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ The following arguments are supported:

* `name` - (Required, string) The name of the network ACL.
* `vpc` - (Optional, Forces new resource, string) The VPC Id. This is a Required field and to be set only when the generation parameter is `2`
* `rules` - (Optional, array) The rules for a network ACL
* `rules` - (Optional, array) The rules for a network ACL. The order of rules priority depends on the order of rules specified in the template.
Nested `rules` blocks have the following structure:
* `name` - (Required, string) The user-defined name for this rule.
* `action` - (Required, string) Whether to allow or deny matching traffic.
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/is_public_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resource "ibm_is_vpc" "testacc_vpc" {
}
resource "ibm_is_public_gateway" "testacc_gateway" {
name = "test_gateway"
name = "test-gateway"
vpc = "${ibm_is_vpc.testacc_vpc.id}"
zone = "us-south-1"
Expand All @@ -44,6 +44,7 @@ The following arguments are supported:
* `name` - (Required, string) The name of the gateway.
* `vpc` - (Required, Forces new resource, string) The vpc id.
* `zone` - (Required, Forces new resource, string) The gateway zone name.
* `resource_group` - (Optional, Forces new resource, string) The resource group ID where the Public gateway is to be created.
* `floating_ip` - (Optional, string) A nested block describing the floating IP of this gateway.
Nested `floating_ip` blocks have the following structure:
* `id` - (Optional, string) ID of the floating ip bound to the public gateway.
Expand Down

0 comments on commit bcb04c7

Please sign in to comment.