ibm.SecurityGroupRule
Explore with Pulumi AI
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
oregress
.ether_type
- (Optional, String) The IP version. Accepted values (case-sensitive):IPv4
orIPv6
. Default value isIPv4
.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 withremote_ip
.remote_ip
- (Optional, String) The CIDR or IP address for allowed connections. Note Conflicts withremote_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
- Security
Group doubleId - Security group ID
- Ether
Type string - IP version IPv4 or IPv6
- Port
Range doubleMax - Port number max range
- Port
Range doubleMin - Port number minimum range
- Protocol string
- icmp, tcp or udp
- Remote
Group doubleId - remote group ID
- Remote
Ip string - Remote IP Address
- Security
Group stringRule Id - (String) The unique identifier of the security group rule.
- Direction string
- Direction of rule: ingress or egress
- Security
Group float64Id - Security group ID
- Ether
Type string - IP version IPv4 or IPv6
- Port
Range float64Max - Port number max range
- Port
Range float64Min - Port number minimum range
- Protocol string
- icmp, tcp or udp
- Remote
Group float64Id - remote group ID
- Remote
Ip string - Remote IP Address
- Security
Group stringRule Id - (String) The unique identifier of the security group rule.
- direction String
- Direction of rule: ingress or egress
- security
Group DoubleId - Security group ID
- ether
Type String - IP version IPv4 or IPv6
- port
Range DoubleMax - Port number max range
- port
Range DoubleMin - Port number minimum range
- protocol String
- icmp, tcp or udp
- remote
Group DoubleId - remote group ID
- remote
Ip String - Remote IP Address
- security
Group StringRule Id - (String) The unique identifier of the security group rule.
- direction string
- Direction of rule: ingress or egress
- security
Group numberId - Security group ID
- ether
Type string - IP version IPv4 or IPv6
- port
Range numberMax - Port number max range
- port
Range numberMin - Port number minimum range
- protocol string
- icmp, tcp or udp
- remote
Group numberId - remote group ID
- remote
Ip string - Remote IP Address
- security
Group stringRule Id - (String) The unique identifier of the security group rule.
- direction str
- Direction of rule: ingress or egress
- security_
group_ floatid - Security group ID
- ether_
type str - IP version IPv4 or IPv6
- port_
range_ floatmax - Port number max range
- port_
range_ floatmin - Port number minimum range
- protocol str
- icmp, tcp or udp
- remote_
group_ floatid - remote group ID
- remote_
ip str - Remote IP Address
- security_
group_ strrule_ id - (String) The unique identifier of the security group rule.
- direction String
- Direction of rule: ingress or egress
- security
Group NumberId - Security group ID
- ether
Type String - IP version IPv4 or IPv6
- port
Range NumberMax - Port number max range
- port
Range NumberMin - Port number minimum range
- protocol String
- icmp, tcp or udp
- remote
Group NumberId - remote group ID
- remote
Ip String - Remote IP Address
- security
Group StringRule Id - (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.
- Direction string
- Direction of rule: ingress or egress
- Ether
Type string - IP version IPv4 or IPv6
- Port
Range doubleMax - Port number max range
- Port
Range doubleMin - Port number minimum range
- Protocol string
- icmp, tcp or udp
- Remote
Group doubleId - remote group ID
- Remote
Ip string - Remote IP Address
- Security
Group doubleId - Security group ID
- Security
Group stringRule Id - (String) The unique identifier of the security group rule.
- Direction string
- Direction of rule: ingress or egress
- Ether
Type string - IP version IPv4 or IPv6
- Port
Range float64Max - Port number max range
- Port
Range float64Min - Port number minimum range
- Protocol string
- icmp, tcp or udp
- Remote
Group float64Id - remote group ID
- Remote
Ip string - Remote IP Address
- Security
Group float64Id - Security group ID
- Security
Group stringRule Id - (String) The unique identifier of the security group rule.
- direction String
- Direction of rule: ingress or egress
- ether
Type String - IP version IPv4 or IPv6
- port
Range DoubleMax - Port number max range
- port
Range DoubleMin - Port number minimum range
- protocol String
- icmp, tcp or udp
- remote
Group DoubleId - remote group ID
- remote
Ip String - Remote IP Address
- security
Group DoubleId - Security group ID
- security
Group StringRule Id - (String) The unique identifier of the security group rule.
- direction string
- Direction of rule: ingress or egress
- ether
Type string - IP version IPv4 or IPv6
- port
Range numberMax - Port number max range
- port
Range numberMin - Port number minimum range
- protocol string
- icmp, tcp or udp
- remote
Group numberId - remote group ID
- remote
Ip string - Remote IP Address
- security
Group numberId - Security group ID
- security
Group stringRule Id - (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_ floatmax - Port number max range
- port_
range_ floatmin - Port number minimum range
- protocol str
- icmp, tcp or udp
- remote_
group_ floatid - remote group ID
- remote_
ip str - Remote IP Address
- security_
group_ floatid - Security group ID
- security_
group_ strrule_ id - (String) The unique identifier of the security group rule.
- direction String
- Direction of rule: ingress or egress
- ether
Type String - IP version IPv4 or IPv6
- port
Range NumberMax - Port number max range
- port
Range NumberMin - Port number minimum range
- protocol String
- icmp, tcp or udp
- remote
Group NumberId - remote group ID
- remote
Ip String - Remote IP Address
- security
Group NumberId - Security group ID
- security
Group StringRule Id - (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.