diff --git a/go.mod b/go.mod index 19cab13c8c..b453662d4c 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/IBM/secrets-manager-go-sdk/v2 v2.0.15 github.com/IBM/vmware-go-sdk v0.1.5 github.com/IBM/vpc-beta-go-sdk v0.8.0 - github.com/IBM/vpc-go-sdk v0.75.0 + github.com/IBM/vpc-go-sdk v0.77.0 github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5 github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2 github.com/akamai/AkamaiOPEN-edgegrid-golang/v5 v5.0.0 diff --git a/go.sum b/go.sum index cdfb7833da..f6a74ca4dc 100644 --- a/go.sum +++ b/go.sum @@ -168,8 +168,8 @@ github.com/IBM/vmware-go-sdk v0.1.5 h1:aQbwcJBceaaauuIoJ0OJn+ttwjb+QTX6XV9Jbrdpj github.com/IBM/vmware-go-sdk v0.1.5/go.mod h1:OyQKRInGGsBaOyE5LIZCqH7b1DZ01BvIYa8BgGy+wWo= github.com/IBM/vpc-beta-go-sdk v0.8.0 h1:cEPpv4iw3Ba5W2d0AWg3TIbKeJ8y1nPuUuibR5Jt9eE= github.com/IBM/vpc-beta-go-sdk v0.8.0/go.mod h1:hORgIyTFRzXrZIK9IohaWmCRBBlYiDRagsufi7M6akE= -github.com/IBM/vpc-go-sdk v0.75.0 h1:8s11vR30n0eY9ptf6Osh9Bw13okhMVasb/KX9M52LEg= -github.com/IBM/vpc-go-sdk v0.75.0/go.mod h1:8lX6TpeYBbx1Vd4KTgM3PPQ4y3auGOPuD6qq3UBDdug= +github.com/IBM/vpc-go-sdk v0.77.0 h1:qAJ1lrwRn509v9yIx3M7pYtBiAucpug+6M/63KS6Er0= +github.com/IBM/vpc-go-sdk v0.77.0/go.mod h1:85bJ/0FS7vYAifHdZvlnXypf8pQSmuf9kxReDDI5ZdY= github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0= github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc= github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= diff --git a/ibm/service/vpc/data_source_ibm_is_security_group.go b/ibm/service/vpc/data_source_ibm_is_security_group.go index 041a5c1003..8babaef618 100644 --- a/ibm/service/vpc/data_source_ibm_is_security_group.go +++ b/ibm/service/vpc/data_source_ibm_is_security_group.go @@ -21,6 +21,7 @@ const ( isSgRuleID = "rule_id" isSgRuleDirection = "direction" isSgRuleIPVersion = "ip_version" + isSgRuleName = "name" isSgRuleRemote = "remote" isSgRuleLocal = "local" isSgRuleType = "type" @@ -92,6 +93,12 @@ func DataSourceIBMISSecurityGroup() *schema.Resource { Description: "IP version: ipv4", }, + isSgRuleName: { + Type: schema.TypeString, + Computed: true, + Description: "The name for this security group rule. The name is unique across all rules in the security group.", + }, + isSgRuleRemote: { Type: schema.TypeString, Computed: true, @@ -310,6 +317,7 @@ func securityGroupGet(context context.Context, d *schema.ResourceData, meta inte } r[isSgRuleDirection] = *rule.Direction r[isSgRuleIPVersion] = *rule.IPVersion + r[isSgRuleName] = rule.Name if rule.Protocol != nil { r[isSgRuleProtocol] = *rule.Protocol } @@ -344,6 +352,7 @@ func securityGroupGet(context context.Context, d *schema.ResourceData, meta inte r := make(map[string]interface{}) r[isSgRuleDirection] = *rule.Direction r[isSgRuleIPVersion] = *rule.IPVersion + r[isSgRuleName] = rule.Name if rule.Protocol != nil { r[isSgRuleProtocol] = *rule.Protocol } @@ -384,6 +393,7 @@ func securityGroupGet(context context.Context, d *schema.ResourceData, meta inte } r[isSgRuleDirection] = *rule.Direction r[isSgRuleIPVersion] = *rule.IPVersion + r[isSgRuleName] = rule.Name if rule.Protocol != nil { r[isSgRuleProtocol] = *rule.Protocol } diff --git a/ibm/service/vpc/data_source_ibm_is_security_group_rule.go b/ibm/service/vpc/data_source_ibm_is_security_group_rule.go index b4e0e3fa5f..14fc2406ff 100644 --- a/ibm/service/vpc/data_source_ibm_is_security_group_rule.go +++ b/ibm/service/vpc/data_source_ibm_is_security_group_rule.go @@ -37,6 +37,11 @@ func DataSourceIBMIsSecurityGroupRule() *schema.Resource { Computed: true, Description: "The direction of traffic to enforce, either `inbound` or `outbound`.", }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name for this security group rule. The name is unique across all rules in the security group.", + }, "href": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -183,6 +188,9 @@ func dataSourceIBMIsSecurityGroupRuleRead(context context.Context, d *schema.Res if err = d.Set("ip_version", securityGroupRule.IPVersion); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting ip_version: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-ip_version").GetDiag() } + if err = d.Set("name", securityGroupRule.Name); err != nil { + return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting name: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-name").GetDiag() + } if err = d.Set("protocol", securityGroupRule.Protocol); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting protocol: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-protocol").GetDiag() } @@ -217,6 +225,9 @@ func dataSourceIBMIsSecurityGroupRuleRead(context context.Context, d *schema.Res if err = d.Set("href", securityGroupRule.Href); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting href: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-href").GetDiag() } + if err = d.Set("name", securityGroupRule.Name); err != nil { + return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting name: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-name").GetDiag() + } if err = d.Set("ip_version", securityGroupRule.IPVersion); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting ip_version: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-ip_version").GetDiag() } @@ -267,6 +278,9 @@ func dataSourceIBMIsSecurityGroupRuleRead(context context.Context, d *schema.Res if err = d.Set("ip_version", securityGroupRule.IPVersion); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting ip_version: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-ip_version").GetDiag() } + if err = d.Set("name", securityGroupRule.Name); err != nil { + return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting name: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-name").GetDiag() + } if err = d.Set("protocol", securityGroupRule.Protocol); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting protocol: %s", err), "(Data) ibm_is_security_group_rule", "read", "set-protocol").GetDiag() } diff --git a/ibm/service/vpc/data_source_ibm_is_security_group_rule_test.go b/ibm/service/vpc/data_source_ibm_is_security_group_rule_test.go index 556133c76f..9ab9ce9d0f 100644 --- a/ibm/service/vpc/data_source_ibm_is_security_group_rule_test.go +++ b/ibm/service/vpc/data_source_ibm_is_security_group_rule_test.go @@ -26,6 +26,7 @@ func TestAccIBMIsSecurityGroupRuleDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rule.example", "direction"), resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rule.example", "href"), resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rule.example", "ip_version"), + resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rule.example", "name"), resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rule.example", "protocol"), resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rule.example", "remote.#"), ), diff --git a/ibm/service/vpc/data_source_ibm_is_security_group_rules.go b/ibm/service/vpc/data_source_ibm_is_security_group_rules.go index 99b36c7cc9..41b6012030 100644 --- a/ibm/service/vpc/data_source_ibm_is_security_group_rules.go +++ b/ibm/service/vpc/data_source_ibm_is_security_group_rules.go @@ -47,6 +47,11 @@ func DataSourceIBMIsSecurityGroupRules() *schema.Resource { Computed: true, Description: "The unique identifier for this security group rule.", }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name for this security group rule. The name is unique across all rules in the security group.", + }, "ip_version": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -186,6 +191,9 @@ func dataSourceIBMIsSecurityGroupRulesRead(context context.Context, d *schema.Re l["direction"] = *rulex.Direction l["href"] = *rulex.Href l["id"] = *rulex.ID + if rulex.Name != nil { + l["name"] = rulex.Name + } l["ip_version"] = *rulex.IPVersion l["protocol"] = *rulex.Protocol // nested map for remote. @@ -210,6 +218,9 @@ func dataSourceIBMIsSecurityGroupRulesRead(context context.Context, d *schema.Re l["direction"] = *rulex.Direction l["href"] = *rulex.Href l["id"] = *rulex.ID + if rulex.Name != nil { + l["name"] = rulex.Name + } l["ip_version"] = *rulex.IPVersion if rulex.Code != nil { l["code"] = *rulex.Code @@ -239,6 +250,9 @@ func dataSourceIBMIsSecurityGroupRulesRead(context context.Context, d *schema.Re l["direction"] = *rulex.Direction l["href"] = *rulex.Href l["id"] = *rulex.ID + if rulex.Name != nil { + l["name"] = rulex.Name + } l["ip_version"] = *rulex.IPVersion l["protocol"] = *rulex.Protocol l["port_max"] = *rulex.PortMax diff --git a/ibm/service/vpc/data_source_ibm_is_security_group_rules_test.go b/ibm/service/vpc/data_source_ibm_is_security_group_rules_test.go index e2dc4fe2c2..22e0bd00ca 100644 --- a/ibm/service/vpc/data_source_ibm_is_security_group_rules_test.go +++ b/ibm/service/vpc/data_source_ibm_is_security_group_rules_test.go @@ -27,6 +27,7 @@ func TestAccIBMIsSecurityGroupRulesDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rules.example", "rules.0.direction"), resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rules.example", "rules.0.href"), resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rules.example", "rules.0.ip_version"), + resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rules.example", "rules.0.name"), resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rules.example", "rules.0.protocol"), resource.TestCheckResourceAttrSet("data.ibm_is_security_group_rules.example", "rules.0.remote.#"), ), diff --git a/ibm/service/vpc/data_source_ibm_is_security_group_test.go b/ibm/service/vpc/data_source_ibm_is_security_group_test.go index 5b8653a435..457fcc07cf 100644 --- a/ibm/service/vpc/data_source_ibm_is_security_group_test.go +++ b/ibm/service/vpc/data_source_ibm_is_security_group_test.go @@ -55,6 +55,7 @@ func TestAccIBMISSecurityGroupDatasource_Filters(t *testing.T) { resource.TestCheckResourceAttr(dataSourceName, "vpc_name", vpcname), resource.TestCheckResourceAttrSet(dataSourceName2, "vpc"), resource.TestCheckResourceAttrSet(dataSourceName2, "rules.#"), + resource.TestCheckResourceAttrSet(dataSourceName2, "rules.name"), resource.TestCheckResourceAttrSet(dataSourceName2, "tags.#"), resource.TestCheckResourceAttr(dataSourceName2, "vpc_name", vpcname2), ), diff --git a/ibm/service/vpc/data_source_ibm_is_security_groups.go b/ibm/service/vpc/data_source_ibm_is_security_groups.go index d552d34b5e..7840e54ebc 100644 --- a/ibm/service/vpc/data_source_ibm_is_security_groups.go +++ b/ibm/service/vpc/data_source_ibm_is_security_groups.go @@ -128,6 +128,11 @@ func DataSourceIBMIsSecurityGroups() *schema.Resource { Computed: true, Description: "The protocol to enforce.", }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name for this security group rule. The name is unique across all rules in the security group.", + }, "local": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -492,6 +497,9 @@ func dataSourceSecurityGroupCollectionSecurityGroupsRulesToMap(rulesItem vpcv1.S if securityGroupRule.Protocol != nil { resultMap["protocol"] = securityGroupRule.Protocol } + if securityGroupRule.Name != nil { + resultMap["name"] = securityGroupRule.Name + } if securityGroupRule.Remote != nil { remoteList := []map[string]interface{}{} remoteMap := dataSourceSecurityGroupsRemoteToMap(*securityGroupRule.Remote.(*vpcv1.SecurityGroupRuleRemote)) @@ -523,6 +531,9 @@ func dataSourceSecurityGroupCollectionSecurityGroupsRulesToMap(rulesItem vpcv1.S if securityGroupRule.Protocol != nil { resultMap["protocol"] = securityGroupRule.Protocol } + if securityGroupRule.Name != nil { + resultMap["name"] = securityGroupRule.Name + } if securityGroupRule.Href != nil { resultMap["href"] = securityGroupRule.Href } @@ -564,6 +575,9 @@ func dataSourceSecurityGroupCollectionSecurityGroupsRulesToMap(rulesItem vpcv1.S if securityGroupRule.Protocol != nil { resultMap["protocol"] = securityGroupRule.Protocol } + if securityGroupRule.Name != nil { + resultMap["name"] = securityGroupRule.Name + } if securityGroupRule.Href != nil { resultMap["href"] = securityGroupRule.Href } diff --git a/ibm/service/vpc/data_source_ibm_is_security_groups_test.go b/ibm/service/vpc/data_source_ibm_is_security_groups_test.go index 3732ec0bf3..1a3a8b2c89 100644 --- a/ibm/service/vpc/data_source_ibm_is_security_groups_test.go +++ b/ibm/service/vpc/data_source_ibm_is_security_groups_test.go @@ -26,6 +26,7 @@ func TestAccIBMIsSecurityGroupsDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_is_security_groups.example", "security_groups.0.name"), resource.TestCheckResourceAttrSet("data.ibm_is_security_groups.example", "security_groups.0.resource_group.#"), resource.TestCheckResourceAttrSet("data.ibm_is_security_groups.example", "security_groups.0.rules.#"), + resource.TestCheckResourceAttrSet("data.ibm_is_security_groups.example", "security_groups.0.rules.name"), resource.TestCheckResourceAttrSet("data.ibm_is_security_groups.example", "security_groups.0.targets.#"), resource.TestCheckResourceAttrSet("data.ibm_is_security_groups.example", "security_groups.0.vpc.#"), ), diff --git a/ibm/service/vpc/data_source_ibm_is_vpc.go b/ibm/service/vpc/data_source_ibm_is_vpc.go index da1f8a0457..7df725eca4 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpc.go +++ b/ibm/service/vpc/data_source_ibm_is_vpc.go @@ -421,6 +421,12 @@ func DataSourceIBMISVPC() *schema.Resource { Computed: true, }, + isVPCSecurityGroupRuleName: { + Type: schema.TypeString, + Computed: true, + Description: "The name for this security group rule. The name must not be used by another rule in the security group.", + }, + isVPCSecurityGroupRulePortMin: { Type: schema.TypeInt, Computed: true, @@ -921,6 +927,9 @@ func setVpcDetails(context context.Context, d *schema.ResourceData, vpc *vpcv1.V if rule.Protocol != nil { r[isVPCSecurityGroupRuleProtocol] = *rule.Protocol } + if rule.Name != nil { + r[isVPCSecurityGroupRuleName] = *rule.Name + } r[isVPCSecurityGroupRuleID] = *rule.ID remote, ok := rule.Remote.(*vpcv1.SecurityGroupRuleRemote) if ok { @@ -943,6 +952,9 @@ func setVpcDetails(context context.Context, d *schema.ResourceData, vpc *vpcv1.V r := make(map[string]interface{}) r[isVPCSecurityGroupRuleDirection] = *rule.Direction r[isVPCSecurityGroupRuleIPVersion] = *rule.IPVersion + if rule.Name != nil { + r[isVPCSecurityGroupRuleName] = *rule.Name + } if rule.Protocol != nil { r[isVPCSecurityGroupRuleProtocol] = *rule.Protocol } @@ -968,6 +980,9 @@ func setVpcDetails(context context.Context, d *schema.ResourceData, vpc *vpcv1.V r := make(map[string]interface{}) r[isVPCSecurityGroupRuleDirection] = *rule.Direction r[isVPCSecurityGroupRuleIPVersion] = *rule.IPVersion + if rule.Name != nil { + r[isVPCSecurityGroupRuleName] = *rule.Name + } if rule.PortMin != nil { r[isVPCSecurityGroupRulePortMin] = int(*rule.PortMin) } diff --git a/ibm/service/vpc/resource_ibm_is_security_group.go b/ibm/service/vpc/resource_ibm_is_security_group.go index 9ae5969327..263614054d 100644 --- a/ibm/service/vpc/resource_ibm_is_security_group.go +++ b/ibm/service/vpc/resource_ibm_is_security_group.go @@ -302,6 +302,9 @@ func resourceIBMISSecurityGroupRead(context context.Context, d *schema.ResourceD r[isSecurityGroupRuleType] = int(*rule.Type) } r[isSecurityGroupRuleDirection] = *rule.Direction + if rule.Name != nil { + r[isSecurityGroupRuleName] = *rule.Name + } r[isSecurityGroupRuleIPVersion] = *rule.IPVersion if rule.Protocol != nil { r[isSecurityGroupRuleProtocol] = *rule.Protocol @@ -336,6 +339,9 @@ func resourceIBMISSecurityGroupRead(context context.Context, d *schema.ResourceD r := make(map[string]interface{}) r[isSecurityGroupRuleDirection] = *rule.Direction r[isSecurityGroupRuleIPVersion] = *rule.IPVersion + if rule.Name != nil { + r[isSecurityGroupRuleName] = *rule.Name + } if rule.Protocol != nil { r[isSecurityGroupRuleProtocol] = *rule.Protocol } @@ -375,6 +381,9 @@ func resourceIBMISSecurityGroupRead(context context.Context, d *schema.ResourceD } r[isSecurityGroupRuleDirection] = *rule.Direction r[isSecurityGroupRuleIPVersion] = *rule.IPVersion + if rule.Name != nil { + r[isSecurityGroupRuleName] = *rule.Name + } if rule.Protocol != nil { r[isSecurityGroupRuleProtocol] = *rule.Protocol } @@ -659,6 +668,12 @@ func makeIBMISSecurityRuleSchema() map[string]*schema.Schema { Description: "IP version: ipv4", }, + isSecurityGroupRuleName: { + Type: schema.TypeString, + Computed: true, + Description: "The name for this security group rule. The name is unique across all rules in the security group.", + }, + isSecurityGroupRuleRemote: { Type: schema.TypeString, Computed: true, diff --git a/ibm/service/vpc/resource_ibm_is_security_group_rule.go b/ibm/service/vpc/resource_ibm_is_security_group_rule.go index bcdfb26163..733a4a77f4 100644 --- a/ibm/service/vpc/resource_ibm_is_security_group_rule.go +++ b/ibm/service/vpc/resource_ibm_is_security_group_rule.go @@ -22,6 +22,7 @@ import ( const ( isSecurityGroupRuleCode = "code" isSecurityGroupRuleDirection = "direction" + isSecurityGroupRuleName = "name" isSecurityGroupRuleIPVersion = "ip_version" isSecurityGroupRuleIPVersionDefault = "ipv4" isSecurityGroupRulePortMax = "port_max" @@ -91,6 +92,13 @@ func ResourceIBMISSecurityGroupRule() *schema.Resource { Description: "Security group id: an IP address, a CIDR block, or a single security group identifier", }, + isSecurityGroupRuleName: { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The name for this security group rule. The name must not be used by another rule in the security group. If unspecified, the name will be a hyphenated list of randomly-selected words.", + }, + isSecurityGroupRuleProtocolICMP: { Type: schema.TypeList, MaxItems: 1, @@ -361,6 +369,9 @@ func resourceIBMISSecurityGroupRuleRead(context context.Context, d *schema.Resou if securityGroupRule.Code != nil { icmpProtocol["code"] = *securityGroupRule.Code } + if securityGroupRule.Name != nil { + icmpProtocol["name"] = *securityGroupRule.Name + } protocolList := make([]map[string]interface{}, 0) protocolList = append(protocolList, icmpProtocol) if err = d.Set(isSecurityGroupRuleProtocolICMP, protocolList); err != nil { @@ -421,6 +432,14 @@ func resourceIBMISSecurityGroupRuleRead(context context.Context, d *schema.Resou return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_security_group_rule", "read", "set-ip_version").GetDiag() } } + + if !core.IsNil(securityGroupRule.Name) { + if err = d.Set("name", securityGroupRule.Name); err != nil { + err = fmt.Errorf("Error setting name: %s", err) + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_security_group_rule", "read", "set-name").GetDiag() + } + } + if err = d.Set("protocol", securityGroupRule.Protocol); err != nil { err = fmt.Errorf("Error setting protocol: %s", err) return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_security_group_rule", "read", "set-protocol").GetDiag() @@ -479,6 +498,12 @@ func resourceIBMISSecurityGroupRuleRead(context context.Context, d *schema.Resou return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_security_group_rule", "read", "set-ip_version").GetDiag() } } + if !core.IsNil(securityGroupRule.Name) { + if err = d.Set("name", securityGroupRule.Name); err != nil { + err = fmt.Errorf("Error setting name: %s", err) + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_security_group_rule", "read", "set-name").GetDiag() + } + } if err = d.Set("protocol", securityGroupRule.Protocol); err != nil { err = fmt.Errorf("Error setting protocol: %s", err) return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_security_group_rule", "read", "set-protocol").GetDiag() @@ -666,6 +691,7 @@ type parsedIBMISSecurityGroupRuleDictionary struct { ruleID string direction string ipversion string + name string remote string remoteAddress string remoteCIDR string @@ -728,6 +754,10 @@ func parseIBMISSecurityGroupRuleDictionary(d *schema.ResourceData, tag string, s sgTemplate.Direction = &parsed.direction securityGroupRulePatchModel.Direction = &parsed.direction + parsed.name = d.Get(isSecurityGroupRuleName).(string) + sgTemplate.Name = &parsed.name + securityGroupRulePatchModel.Name = &parsed.name + if version, ok := d.GetOk(isSecurityGroupRuleIPVersion); ok { parsed.ipversion = version.(string) sgTemplate.IPVersion = &parsed.ipversion diff --git a/ibm/service/vpc/resource_ibm_is_vpc.go b/ibm/service/vpc/resource_ibm_is_vpc.go index fbe45e3c3f..3479362c3b 100644 --- a/ibm/service/vpc/resource_ibm_is_vpc.go +++ b/ibm/service/vpc/resource_ibm_is_vpc.go @@ -60,6 +60,7 @@ const ( isVPCSecurityGroupRuleRemote = "remote" isVPCSecurityGroupRuleType = "type" isVPCSecurityGroupRuleCode = "code" + isVPCSecurityGroupRuleName = "name" isVPCSecurityGroupRulePortMax = "port_max" isVPCSecurityGroupRulePortMin = "port_min" isVPCSecurityGroupRuleProtocol = "protocol" diff --git a/website/docs/d/is_security_group.html.markdown b/website/docs/d/is_security_group.html.markdown index 32a92c4fc5..54438a8ca4 100644 --- a/website/docs/d/is_security_group.html.markdown +++ b/website/docs/d/is_security_group.html.markdown @@ -102,6 +102,7 @@ In addition to all argument reference list, you can access the following attribu - `ip_version` - (String) IP version: IPv4 - `protocol` - (String) The type of the protocol `all`, `icmp`, `tcp`, `udp`. - `type` - (String) The traffic type to allow. + - `name` - (String) The name for this security group rule. The name must not be used by another rule in the security group. - `code` - (String) The traffic code to allow. - `port_max`- (Integer) The TCP/UDP port range that includes the maximum bound. - `port_min`- (Integer) The TCP/UDP port range that includes the minimum bound. diff --git a/website/docs/d/is_security_group_rule.html.markdown b/website/docs/d/is_security_group_rule.html.markdown index 4c52e3907c..c38b51762b 100644 --- a/website/docs/d/is_security_group_rule.html.markdown +++ b/website/docs/d/is_security_group_rule.html.markdown @@ -39,6 +39,8 @@ In addition to all argument references listed, you can access the following attr - `href` - (String) The URL for this security group rule. +- `name` - (String) The name for this security group rule. The name must not be used by another rule in the security group. + - `local` - (List) The local IP address or range of local IP addresses to which this rule will allow inbound traffic (or from which, for outbound traffic). A CIDR block of 0.0.0.0/0 allows traffic to all local IP addresses (or from all local IP addresses, for outbound rules). Nested scheme for `local`: diff --git a/website/docs/d/is_security_group_rules.html.markdown b/website/docs/d/is_security_group_rules.html.markdown index 6539bb7fbc..1ffb3c08d1 100644 --- a/website/docs/d/is_security_group_rules.html.markdown +++ b/website/docs/d/is_security_group_rules.html.markdown @@ -36,6 +36,7 @@ Nested scheme for `rules`: - `direction` - (String) The direction of traffic to enforce, either `inbound` or `outbound`. - `href` - (String) The URL for this security group rule. - `id` - (String) The unique identifier for this security group rule. + - `name` - (String) The name for this security group rule. The name must not be used by another rule in the security group. - `ip_version` - (String) The IP version to enforce. The format of `remote.address` or `remote.cidr_block` must match this property, if they are used. Alternatively, if `remote` references a security group, then this rule only applies to IP addresses (network interfaces) in that group matching this IP version. - `local` - (List) The local IP address or range of local IP addresses to which this rule will allow inbound traffic (or from which, for outbound traffic). A CIDR block of 0.0.0.0/0 allows traffic to all local IP addresses (or from all local IP addresses, for outbound rules). diff --git a/website/docs/d/is_security_groups.html.markdown b/website/docs/d/is_security_groups.html.markdown index 8b08fb0f0b..2497411cc2 100644 --- a/website/docs/d/is_security_groups.html.markdown +++ b/website/docs/d/is_security_groups.html.markdown @@ -83,6 +83,7 @@ In addition to all argument references listed, you can access the following attr - `direction` - (String) The direction of traffic to enforce, either `inbound` or `outbound`. - `href` - (String) The URL for this security group rule. - `id` - (String) The unique identifier for this security group rule. + - `name` - (String) The name for this security group rule. The name must not be used by another rule in the security group. - `ip_version` - (String) The IP version to enforce. The format of `remote.address` or `remote.cidr_block` must match this property, if they are used. Alternatively, if `remote` references a security group, then this rule only applies to IP addresses (network interfaces) in that group matching this IP version. - `local` - (List) The local IP address or range of local IP addresses to which this rule will allow inbound traffic (or from which, for outbound traffic). A CIDR block of 0.0.0.0/0 allows traffic to all local IP addresses (or from all local IP addresses, for outbound rules). diff --git a/website/docs/d/is_vpc.html.markdown b/website/docs/d/is_vpc.html.markdown index f5d86d23b5..4a0d1aeb41 100644 --- a/website/docs/d/is_vpc.html.markdown +++ b/website/docs/d/is_vpc.html.markdown @@ -111,6 +111,7 @@ In addition to all argument reference list, you can access the following attribu - `port_max` - (String) The inclusive upper bound of TCP port range. - `remote` - (String) The security group ID, an IP address, a CIDR block, or a single security group identifier. - `rule_id` - (String) ID of the rule. + - `name` - (String) The name for this security group rule. The name must not be used by another rule in the security group. - `type` - (String) The ICMP traffic type to allow. - `status` - (String) The status of the VPC. - `subnets`- (List) A list of subnets that are attached to a VPC. diff --git a/website/docs/r/is_security_group.html.markdown b/website/docs/r/is_security_group.html.markdown index 020e824a05..772a754eae 100644 --- a/website/docs/r/is_security_group.html.markdown +++ b/website/docs/r/is_security_group.html.markdown @@ -63,6 +63,7 @@ In addition to all argument reference list, you can access the following attribu - `ip_version` - (String) IP version: `ipv4` - `local` - (String) The local IP address or range of local IP addresses to which this rule will allow inbound traffic (or from which, for outbound traffic). A CIDR block of 0.0.0.0/0 allows traffic to all local IP addresses (or from all local IP addresses, for outbound rules). an IP address, a `CIDR` block. - `protocol` - (String) The type of the protocol `all`, `icmp`, `tcp`, `udp`. + - `name` - (String) The name for this security group rule. The name must not be used by another rule in the security group. - `port_max`- (Integer) The `TCP/UDP` port range that includes the maximum bound. - `port_min`- (Integer) The `TCP/UDP` port range that includes the minimum bound. - `remote` - (String) Security group id, an IP address, a `CIDR` block, or a single security group identifier. diff --git a/website/docs/r/is_security_group_rule.html.markdown b/website/docs/r/is_security_group_rule.html.markdown index 8cca901a0f..1b99c0bc6a 100644 --- a/website/docs/r/is_security_group_rule.html.markdown +++ b/website/docs/r/is_security_group_rule.html.markdown @@ -92,6 +92,7 @@ resource "ibm_is_security_group_rule" "example_security_group_rule_tcp_any" { remote = "127.0.0.1" tcp { } + name = "my-test-sg-rule-name" } ``` @@ -104,6 +105,7 @@ Review the argument references that you can specify for your resource. - `local` - (String) The local IP address or range of local IP addresses to which this rule will allow inbound traffic (or from which, for outbound traffic). A CIDR block of 0.0.0.0/0 allows traffic to all local IP addresses (or from all local IP addresses, for outbound rules). an IP address, a `CIDR` block. - `ip_version` - (Optional, String) The IP version to enforce. The format of local.address, remote.address, local.cidr_block or remote.cidr_block must match this property, if they are used. If remote references a security group, then this rule only applies to IP addresses (network interfaces) in that group matching this IP version. Supported value is [`ipv4`]. - `icmp` - (Optional, List) A nested block describes the `icmp` protocol of this security group rule. +- `name` - (String) The name for this security group rule. The name must not be used by another rule in the security group. Nested scheme for `icmp`: - `type`- (Optional, Integer) The ICMP traffic type to allow. Valid values from 0 to 254. If unspecified, all codes are allowed.