From bcb04c7951eb20d86f293117bd573bfe4974390a Mon Sep 17 00:00:00 2001 From: vaishnavi Date: Mon, 24 Feb 2020 18:07:03 +0530 Subject: [PATCH] V11 Fix for issue #1117, #1102 --- examples/ibm-is-vpc/main.tf | 19 ++++++++++++++----- ibm/resource_ibm_is_networkacls.go | 6 ++---- ibm/resource_ibm_is_public_gateway.go | 17 ++++++++++++++++- .../clients/compute/instance.go | 9 --------- .../clients/network/publicgateways.go | 10 +++++++++- .../riaas-go-client/clients/network/subnet.go | 6 ++---- .../network/post_public_gateways_responses.go | 2 +- .../riaas-go-client/swagger/swagger.yaml | 2 +- vendor/vendor.json | 6 +++--- website/docs/r/is_network_acl.html.markdown | 2 +- .../docs/r/is_public_gateway.html.markdown | 3 ++- 11 files changed, 51 insertions(+), 31 deletions(-) diff --git a/examples/ibm-is-vpc/main.tf b/examples/ibm-is-vpc/main.tf index 9ce53be7b5..a250ae5c7d 100644 --- a/examples/ibm-is-vpc/main.tf +++ b/examples/ibm-is-vpc/main.tf @@ -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}" @@ -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}" } @@ -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}" } @@ -217,15 +217,16 @@ 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 @@ -233,12 +234,14 @@ resource "ibm_is_network_acl" "isExampleACL" { 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 @@ -246,4 +249,10 @@ resource "ibm_is_network_acl" "isExampleACL" { source_port_min = 22 } } -} \ No newline at end of file +} + +resource "ibm_is_public_gateway" "publicgateway1" { + name = "pg1" + vpc = "${ibm_is_vpc.vpc1.id}" + zone = "${var.zone1}" +} diff --git a/ibm/resource_ibm_is_networkacls.go b/ibm/resource_ibm_is_networkacls.go index 3f6a4fe28c..3292c6f67c 100644 --- a/ibm/resource_ibm_is_networkacls.go +++ b/ibm/resource_ibm_is_networkacls.go @@ -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) @@ -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 } diff --git a/ibm/resource_ibm_is_public_gateway.go b/ibm/resource_ibm_is_public_gateway.go index e0b4beb3b8..9fd71a9098 100644 --- a/ibm/resource_ibm_is_public_gateway.go +++ b/ibm/resource_ibm_is_public_gateway.go @@ -17,6 +17,7 @@ const ( isPublicGatewayVPC = "vpc" isPublicGatewayZone = "zone" isPublicGatewayFloatingIPAddress = "address" + isPublicGatewayResourceGroup = "resource_group" isPublicGatewayProvisioning = "provisioning" isPublicGatewayProvisioningDone = "available" @@ -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, @@ -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 { @@ -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 } @@ -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 { diff --git a/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/compute/instance.go b/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/compute/instance.go index 112b04ae8b..6fa20259e5 100644 --- a/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/compute/instance.go +++ b/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/compute/instance.go @@ -103,15 +103,6 @@ func (f *InstanceClient) Create(instancedef compute.PostInstancesBody) (*models. return resp.Payload, nil } -// CreateEasy ... -func (f *InstanceClient) CreateEasy(name string) (*models.Instance, error) { - - var body = compute.PostInstancesBody{ - Name: name, - } - return f.Create(body) -} - // Update ... func (f *InstanceClient) Update(id, name, profileName string) (*models.Instance, error) { var body = compute.PatchInstancesIDBody{} diff --git a/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/network/publicgateways.go b/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/network/publicgateways.go index 190fddf746..29158f6af8 100644 --- a/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/network/publicgateways.go +++ b/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/network/publicgateways.go @@ -60,7 +60,7 @@ func (f *PublicGatewayClient) Get(id string) (*models.PublicGateway, error) { } /// Create ... -func (f *PublicGatewayClient) Create(name, zoneName, vpcID, FloatingIPID, FloatingIPaddr string) (*models.PublicGateway, error) { +func (f *PublicGatewayClient) Create(name, zoneName, vpcID, FloatingIPID, FloatingIPaddr, resourcegroupID string) (*models.PublicGateway, error) { var body = network.PostPublicGatewaysBody{ Name: name, @@ -88,6 +88,14 @@ func (f *PublicGatewayClient) Create(name, zoneName, vpcID, FloatingIPID, Floati } body.FloatingIP = &floatingip } + + if resourcegroupID != "" { + var resourcegroup = network.PostPublicGatewaysParamsBodyResourceGroup{ + ID: strfmt.UUID(resourcegroupID), + } + body.ResourceGroup = &resourcegroup + } + params := network.NewPostPublicGatewaysParamsWithTimeout(f.session.Timeout).WithBody(body) params.Version = "2019-10-08" params.Generation = f.session.Generation diff --git a/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/network/subnet.go b/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/network/subnet.go index 84124a4599..4a9b91ff79 100644 --- a/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/network/subnet.go +++ b/vendor/github.ibm.com/Bluemix/riaas-go-client/clients/network/subnet.go @@ -98,17 +98,15 @@ func (f *SubnetClient) Create(name, zoneName, vpcID, networkaclID, publicgwID, } if publicgwID != "" { - publicgwUUID := strfmt.UUID(publicgwID) var pubgw = network.PostSubnetsParamsBodyPublicGateway{ - ID: publicgwUUID, + ID: strfmt.UUID(publicgwID), } body.PublicGateway = &pubgw } if resourcegroupID != "" { - resourcegroupuuid := strfmt.UUID(resourcegroupID) var resourcegroup = network.PostSubnetsParamsBodyResourceGroup{ - ID: resourcegroupuuid, + ID: strfmt.UUID(resourcegroupID), } body.ResourceGroup = &resourcegroup } diff --git a/vendor/github.ibm.com/Bluemix/riaas-go-client/riaas/client/network/post_public_gateways_responses.go b/vendor/github.ibm.com/Bluemix/riaas-go-client/riaas/client/network/post_public_gateways_responses.go index cf57af4168..fb1fb4e057 100644 --- a/vendor/github.ibm.com/Bluemix/riaas-go-client/riaas/client/network/post_public_gateways_responses.go +++ b/vendor/github.ibm.com/Bluemix/riaas-go-client/riaas/client/network/post_public_gateways_responses.go @@ -361,7 +361,7 @@ func (o *PostPublicGatewaysParamsBodyFloatingIP) UnmarshalBinary(b []byte) error /*PostPublicGatewaysParamsBodyResourceGroup ResourceGroupIdentity // -// The resource group for this network ACL +// The resource group for this public gateway swagger:model PostPublicGatewaysParamsBodyResourceGroup */ type PostPublicGatewaysParamsBodyResourceGroup struct { diff --git a/vendor/github.ibm.com/Bluemix/riaas-go-client/swagger/swagger.yaml b/vendor/github.ibm.com/Bluemix/riaas-go-client/swagger/swagger.yaml index 49fdf9c3c1..71cd003356 100644 --- a/vendor/github.ibm.com/Bluemix/riaas-go-client/swagger/swagger.yaml +++ b/vendor/github.ibm.com/Bluemix/riaas-go-client/swagger/swagger.yaml @@ -4863,7 +4863,7 @@ paths: title: FloatingIPTemplateBasic type: object resource_group: - description: The resource group for this network ACL + description: The resource group for this public gateway properties: id: {description: The unique identifier for this resource group, example: 56969d60-43e9-465c-883c-b9f7363e78e8, format: uuid, pattern: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$', diff --git a/vendor/vendor.json b/vendor/vendor.json index c1d63f8826..084f8c6f2d 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -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 }, { diff --git a/website/docs/r/is_network_acl.html.markdown b/website/docs/r/is_network_acl.html.markdown index 2e58b173a8..bcaf0f404b 100644 --- a/website/docs/r/is_network_acl.html.markdown +++ b/website/docs/r/is_network_acl.html.markdown @@ -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. diff --git a/website/docs/r/is_public_gateway.html.markdown b/website/docs/r/is_public_gateway.html.markdown index b9cdbf788f..c70eec577e 100644 --- a/website/docs/r/is_public_gateway.html.markdown +++ b/website/docs/r/is_public_gateway.html.markdown @@ -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" @@ -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.