1. Packages
  2. Ibm Provider
  3. API Docs
  4. SecurityGroupRule
ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud

ibm.SecurityGroupRule

Explore with Pulumi AI

ibm logo
ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud

    Create, delete, and update a rule for a security group. You can set the IP range to manage incoming (ingress) and outgoing (egress) traffic to a virtual server instance. To create the security group, use the security_group resource. For more information, about security group rule, see about security group.

    Note

    For more information, see IBM Cloud Classic Infrastructure (SoftLayer) API documentation.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ibm from "@pulumi/ibm";
    
    const allowPort8080 = new ibm.SecurityGroupRule("allowPort8080", {
        direction: "ingress",
        etherType: "IPv4",
        portRangeMax: 8080,
        portRangeMin: 8080,
        protocol: "tcp",
        securityGroupId: 123456,
    });
    
    import pulumi
    import pulumi_ibm as ibm
    
    allow_port8080 = ibm.SecurityGroupRule("allowPort8080",
        direction="ingress",
        ether_type="IPv4",
        port_range_max=8080,
        port_range_min=8080,
        protocol="tcp",
        security_group_id=123456)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ibm.NewSecurityGroupRule(ctx, "allowPort8080", &ibm.SecurityGroupRuleArgs{
    			Direction:       pulumi.String("ingress"),
    			EtherType:       pulumi.String("IPv4"),
    			PortRangeMax:    pulumi.Float64(8080),
    			PortRangeMin:    pulumi.Float64(8080),
    			Protocol:        pulumi.String("tcp"),
    			SecurityGroupId: pulumi.Float64(123456),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ibm = Pulumi.Ibm;
    
    return await Deployment.RunAsync(() => 
    {
        var allowPort8080 = new Ibm.SecurityGroupRule("allowPort8080", new()
        {
            Direction = "ingress",
            EtherType = "IPv4",
            PortRangeMax = 8080,
            PortRangeMin = 8080,
            Protocol = "tcp",
            SecurityGroupId = 123456,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ibm.SecurityGroupRule;
    import com.pulumi.ibm.SecurityGroupRuleArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var allowPort8080 = new SecurityGroupRule("allowPort8080", SecurityGroupRuleArgs.builder()
                .direction("ingress")
                .etherType("IPv4")
                .portRangeMax(8080)
                .portRangeMin(8080)
                .protocol("tcp")
                .securityGroupId(123456)
                .build());
    
        }
    }
    
    resources:
      allowPort8080:
        type: ibm:SecurityGroupRule
        properties:
          direction: ingress
          etherType: IPv4
          portRangeMax: 8080
          portRangeMin: 8080
          protocol: tcp
          securityGroupId: 123456
    

    Argument reference

    Review the argument references that you can specify for your resource.

    • direction - (Required, String) The direction of traffic. Accepted values: ingress or egress.
    • ether_type- (Optional, String) The IP version. Accepted values (case-sensitive): IPv4 or IPv6. Default value is IPv4.
    • port_range_min - (Optional, Integer) The start of the port range for allowed traffic.
    • port_range_max - (Optional, Integer) The end of the port range for allowed traffic.
    • protocol- (Optional, String) The IP protocol type. Accepted values (case-sensitive): icmp,tcp, or udp.
    • remote_group_id - (Optional, Integer) The ID of the remote security group allowed as part of the rule. Note Conflicts with remote_ip.
    • remote_ip- (Optional, String) The CIDR or IP address for allowed connections. Note Conflicts with remote_group_id.
    • security_group_id - (Required, Forces new resource, Integer) The ID of the security group this rule belongs to.

    Create SecurityGroupRule Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new SecurityGroupRule(name: string, args: SecurityGroupRuleArgs, opts?: CustomResourceOptions);
    @overload
    def SecurityGroupRule(resource_name: str,
                          args: SecurityGroupRuleArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def SecurityGroupRule(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          direction: Optional[str] = None,
                          security_group_id: Optional[float] = None,
                          ether_type: Optional[str] = None,
                          port_range_max: Optional[float] = None,
                          port_range_min: Optional[float] = None,
                          protocol: Optional[str] = None,
                          remote_group_id: Optional[float] = None,
                          remote_ip: Optional[str] = None,
                          security_group_rule_id: Optional[str] = None)
    func NewSecurityGroupRule(ctx *Context, name string, args SecurityGroupRuleArgs, opts ...ResourceOption) (*SecurityGroupRule, error)
    public SecurityGroupRule(string name, SecurityGroupRuleArgs args, CustomResourceOptions? opts = null)
    public SecurityGroupRule(String name, SecurityGroupRuleArgs args)
    public SecurityGroupRule(String name, SecurityGroupRuleArgs args, CustomResourceOptions options)
    
    type: ibm:SecurityGroupRule
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args SecurityGroupRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args SecurityGroupRuleArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args SecurityGroupRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SecurityGroupRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SecurityGroupRuleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var securityGroupRuleResource = new Ibm.SecurityGroupRule("securityGroupRuleResource", new()
    {
        Direction = "string",
        SecurityGroupId = 0,
        EtherType = "string",
        PortRangeMax = 0,
        PortRangeMin = 0,
        Protocol = "string",
        RemoteGroupId = 0,
        RemoteIp = "string",
        SecurityGroupRuleId = "string",
    });
    
    example, err := ibm.NewSecurityGroupRule(ctx, "securityGroupRuleResource", &ibm.SecurityGroupRuleArgs{
    	Direction:           pulumi.String("string"),
    	SecurityGroupId:     pulumi.Float64(0),
    	EtherType:           pulumi.String("string"),
    	PortRangeMax:        pulumi.Float64(0),
    	PortRangeMin:        pulumi.Float64(0),
    	Protocol:            pulumi.String("string"),
    	RemoteGroupId:       pulumi.Float64(0),
    	RemoteIp:            pulumi.String("string"),
    	SecurityGroupRuleId: pulumi.String("string"),
    })
    
    var securityGroupRuleResource = new SecurityGroupRule("securityGroupRuleResource", SecurityGroupRuleArgs.builder()
        .direction("string")
        .securityGroupId(0)
        .etherType("string")
        .portRangeMax(0)
        .portRangeMin(0)
        .protocol("string")
        .remoteGroupId(0)
        .remoteIp("string")
        .securityGroupRuleId("string")
        .build());
    
    security_group_rule_resource = ibm.SecurityGroupRule("securityGroupRuleResource",
        direction="string",
        security_group_id=0,
        ether_type="string",
        port_range_max=0,
        port_range_min=0,
        protocol="string",
        remote_group_id=0,
        remote_ip="string",
        security_group_rule_id="string")
    
    const securityGroupRuleResource = new ibm.SecurityGroupRule("securityGroupRuleResource", {
        direction: "string",
        securityGroupId: 0,
        etherType: "string",
        portRangeMax: 0,
        portRangeMin: 0,
        protocol: "string",
        remoteGroupId: 0,
        remoteIp: "string",
        securityGroupRuleId: "string",
    });
    
    type: ibm:SecurityGroupRule
    properties:
        direction: string
        etherType: string
        portRangeMax: 0
        portRangeMin: 0
        protocol: string
        remoteGroupId: 0
        remoteIp: string
        securityGroupId: 0
        securityGroupRuleId: string
    

    SecurityGroupRule Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The SecurityGroupRule resource accepts the following input properties:

    Direction string
    Direction of rule: ingress or egress
    SecurityGroupId double
    Security group ID
    EtherType string
    IP version IPv4 or IPv6
    PortRangeMax double
    Port number max range
    PortRangeMin double
    Port number minimum range
    Protocol string
    icmp, tcp or udp
    RemoteGroupId double
    remote group ID
    RemoteIp string
    Remote IP Address
    SecurityGroupRuleId string
    (String) The unique identifier of the security group rule.
    Direction string
    Direction of rule: ingress or egress
    SecurityGroupId float64
    Security group ID
    EtherType string
    IP version IPv4 or IPv6
    PortRangeMax float64
    Port number max range
    PortRangeMin float64
    Port number minimum range
    Protocol string
    icmp, tcp or udp
    RemoteGroupId float64
    remote group ID
    RemoteIp string
    Remote IP Address
    SecurityGroupRuleId string
    (String) The unique identifier of the security group rule.
    direction String
    Direction of rule: ingress or egress
    securityGroupId Double
    Security group ID
    etherType String
    IP version IPv4 or IPv6
    portRangeMax Double
    Port number max range
    portRangeMin Double
    Port number minimum range
    protocol String
    icmp, tcp or udp
    remoteGroupId Double
    remote group ID
    remoteIp String
    Remote IP Address
    securityGroupRuleId String
    (String) The unique identifier of the security group rule.
    direction string
    Direction of rule: ingress or egress
    securityGroupId number
    Security group ID
    etherType string
    IP version IPv4 or IPv6
    portRangeMax number
    Port number max range
    portRangeMin number
    Port number minimum range
    protocol string
    icmp, tcp or udp
    remoteGroupId number
    remote group ID
    remoteIp string
    Remote IP Address
    securityGroupRuleId string
    (String) The unique identifier of the security group rule.
    direction str
    Direction of rule: ingress or egress
    security_group_id float
    Security group ID
    ether_type str
    IP version IPv4 or IPv6
    port_range_max float
    Port number max range
    port_range_min float
    Port number minimum range
    protocol str
    icmp, tcp or udp
    remote_group_id float
    remote group ID
    remote_ip str
    Remote IP Address
    security_group_rule_id str
    (String) The unique identifier of the security group rule.
    direction String
    Direction of rule: ingress or egress
    securityGroupId Number
    Security group ID
    etherType String
    IP version IPv4 or IPv6
    portRangeMax Number
    Port number max range
    portRangeMin Number
    Port number minimum range
    protocol String
    icmp, tcp or udp
    remoteGroupId Number
    remote group ID
    remoteIp String
    Remote IP Address
    securityGroupRuleId String
    (String) The unique identifier of the security group rule.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the SecurityGroupRule resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing SecurityGroupRule Resource

    Get an existing SecurityGroupRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: SecurityGroupRuleState, opts?: CustomResourceOptions): SecurityGroupRule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            direction: Optional[str] = None,
            ether_type: Optional[str] = None,
            port_range_max: Optional[float] = None,
            port_range_min: Optional[float] = None,
            protocol: Optional[str] = None,
            remote_group_id: Optional[float] = None,
            remote_ip: Optional[str] = None,
            security_group_id: Optional[float] = None,
            security_group_rule_id: Optional[str] = None) -> SecurityGroupRule
    func GetSecurityGroupRule(ctx *Context, name string, id IDInput, state *SecurityGroupRuleState, opts ...ResourceOption) (*SecurityGroupRule, error)
    public static SecurityGroupRule Get(string name, Input<string> id, SecurityGroupRuleState? state, CustomResourceOptions? opts = null)
    public static SecurityGroupRule get(String name, Output<String> id, SecurityGroupRuleState state, CustomResourceOptions options)
    resources:  _:    type: ibm:SecurityGroupRule    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Direction string
    Direction of rule: ingress or egress
    EtherType string
    IP version IPv4 or IPv6
    PortRangeMax double
    Port number max range
    PortRangeMin double
    Port number minimum range
    Protocol string
    icmp, tcp or udp
    RemoteGroupId double
    remote group ID
    RemoteIp string
    Remote IP Address
    SecurityGroupId double
    Security group ID
    SecurityGroupRuleId string
    (String) The unique identifier of the security group rule.
    Direction string
    Direction of rule: ingress or egress
    EtherType string
    IP version IPv4 or IPv6
    PortRangeMax float64
    Port number max range
    PortRangeMin float64
    Port number minimum range
    Protocol string
    icmp, tcp or udp
    RemoteGroupId float64
    remote group ID
    RemoteIp string
    Remote IP Address
    SecurityGroupId float64
    Security group ID
    SecurityGroupRuleId string
    (String) The unique identifier of the security group rule.
    direction String
    Direction of rule: ingress or egress
    etherType String
    IP version IPv4 or IPv6
    portRangeMax Double
    Port number max range
    portRangeMin Double
    Port number minimum range
    protocol String
    icmp, tcp or udp
    remoteGroupId Double
    remote group ID
    remoteIp String
    Remote IP Address
    securityGroupId Double
    Security group ID
    securityGroupRuleId String
    (String) The unique identifier of the security group rule.
    direction string
    Direction of rule: ingress or egress
    etherType string
    IP version IPv4 or IPv6
    portRangeMax number
    Port number max range
    portRangeMin number
    Port number minimum range
    protocol string
    icmp, tcp or udp
    remoteGroupId number
    remote group ID
    remoteIp string
    Remote IP Address
    securityGroupId number
    Security group ID
    securityGroupRuleId string
    (String) The unique identifier of the security group rule.
    direction str
    Direction of rule: ingress or egress
    ether_type str
    IP version IPv4 or IPv6
    port_range_max float
    Port number max range
    port_range_min float
    Port number minimum range
    protocol str
    icmp, tcp or udp
    remote_group_id float
    remote group ID
    remote_ip str
    Remote IP Address
    security_group_id float
    Security group ID
    security_group_rule_id str
    (String) The unique identifier of the security group rule.
    direction String
    Direction of rule: ingress or egress
    etherType String
    IP version IPv4 or IPv6
    portRangeMax Number
    Port number max range
    portRangeMin Number
    Port number minimum range
    protocol String
    icmp, tcp or udp
    remoteGroupId Number
    remote group ID
    remoteIp String
    Remote IP Address
    securityGroupId Number
    Security group ID
    securityGroupRuleId String
    (String) The unique identifier of the security group rule.

    Package Details

    Repository
    ibm ibm-cloud/terraform-provider-ibm
    License
    Notes
    This Pulumi package is based on the ibm Terraform Provider.
    ibm logo
    ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud