GetSecurityGroupRules
The alicloud.ecs.getSecurityGroupRules data source provides a collection of security permissions of a specific security group.
Each collection item represents a single ingress or egress permission rule.
The ID of the security group can be provided via a variable or the result from the other data source alicloud.ecs.getSecurityGroups.
Example Usage
using Pulumi;
using AliCloud = Pulumi.AliCloud;
class MyStack : Stack
{
public MyStack()
{
var config = new Config();
var securityGroupId = config.RequireObject<dynamic>("securityGroupId");
var groupsDs = Output.Create(AliCloud.Ecs.GetSecurityGroups.InvokeAsync(new AliCloud.Ecs.GetSecurityGroupsArgs
{
NameRegex = "api",
}));
var ingressRulesDs = groupsDs.Apply(groupsDs => Output.Create(AliCloud.Ecs.GetSecurityGroupRules.InvokeAsync(new AliCloud.Ecs.GetSecurityGroupRulesArgs
{
Direction = "ingress",
GroupId = groupsDs.Groups[0].Id,
IpProtocol = "TCP",
NicType = "internet",
})));
// Pass port_range to the backend service
var backend = new AliCloud.Ecs.Instance("backend", new AliCloud.Ecs.InstanceArgs
{
UserData = ingressRulesDs.Apply(ingressRulesDs => $"config_service.sh --portrange={ingressRulesDs.Rules[0].PortRange}"),
});
}
}
Coming soon!
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
security_group_id = config.require_object("securityGroupId")
groups_ds = alicloud.ecs.get_security_groups(name_regex="api")
ingress_rules_ds = alicloud.ecs.get_security_group_rules(direction="ingress",
group_id=groups_ds.groups[0]["id"],
ip_protocol="TCP",
nic_type="internet")
# Pass port_range to the backend service
backend = alicloud.ecs.Instance("backend", user_data=f"config_service.sh --portrange={ingress_rules_ds.rules[0]['port_range']}")import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
// Get the security group id from a variable
const securityGroupId = config.require("securityGroupId");
// Or get it from the alicloud.ecs.getSecurityGroups data source.
// Please note that the data source arguments must be enough to filter results to one security group.
const groupsDs = pulumi.output(alicloud.ecs.getSecurityGroups({
nameRegex: "api",
}, { async: true }));
// Filter the security group rule by group
const ingressRulesDs = groupsDs.apply(groupsDs => alicloud.ecs.getSecurityGroupRules({
direction: "ingress",
groupId: groupsDs.groups[0].id,
ipProtocol: "TCP",
nicType: "internet",
}, { async: true }));
// Pass port_range to the backend service
const backend = new alicloud.ecs.Instance("backend", {
userData: pulumi.interpolate`config_service.sh --portrange=${ingressRulesDs.rules[0].portRange}`,
});Using GetSecurityGroupRules
function getSecurityGroupRules(args: GetSecurityGroupRulesArgs, opts?: InvokeOptions): Promise<GetSecurityGroupRulesResult>function get_security_group_rules(direction=None, group_id=None, ip_protocol=None, nic_type=None, output_file=None, policy=None, opts=None)func GetSecurityGroupRules(ctx *Context, args *GetSecurityGroupRulesArgs, opts ...InvokeOption) (*GetSecurityGroupRulesResult, error)public static class GetSecurityGroupRules {
public static Task<GetSecurityGroupRulesResult> InvokeAsync(GetSecurityGroupRulesArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Group
Id string The ID of the security group that owns the rules.
- Direction string
Authorization direction. Valid values are:
ingressoregress.- Ip
Protocol string The IP protocol. Valid values are:
tcp,udp,icmp,greandall.- Nic
Type string Refers to the network type. Can be either
internetorintranet. The default value isinternet.- Output
File string - Policy string
Authorization policy. Can be either
acceptordrop. The default value isaccept.
- Group
Id string The ID of the security group that owns the rules.
- Direction string
Authorization direction. Valid values are:
ingressoregress.- Ip
Protocol string The IP protocol. Valid values are:
tcp,udp,icmp,greandall.- Nic
Type string Refers to the network type. Can be either
internetorintranet. The default value isinternet.- Output
File string - Policy string
Authorization policy. Can be either
acceptordrop. The default value isaccept.
- group
Id string The ID of the security group that owns the rules.
- direction string
Authorization direction. Valid values are:
ingressoregress.- ip
Protocol string The IP protocol. Valid values are:
tcp,udp,icmp,greandall.- nic
Type string Refers to the network type. Can be either
internetorintranet. The default value isinternet.- output
File string - policy string
Authorization policy. Can be either
acceptordrop. The default value isaccept.
- group_
id str The ID of the security group that owns the rules.
- direction str
Authorization direction. Valid values are:
ingressoregress.- ip_
protocol str The IP protocol. Valid values are:
tcp,udp,icmp,greandall.- nic_
type str Refers to the network type. Can be either
internetorintranet. The default value isinternet.- output_
file str - policy str
Authorization policy. Can be either
acceptordrop. The default value isaccept.
GetSecurityGroupRules Result
The following output properties are available:
- Group
Desc string The description of the security group that owns the rules.
- Group
Id string - Group
Name string The name of the security group that owns the rules.
- Id string
The provider-assigned unique ID for this managed resource.
- Rules
List<Pulumi.
Ali Cloud. Ecs. Outputs. Get Security Group Rules Rule> A list of security group rules. Each element contains the following attributes:
- Direction string
Authorization direction,
ingressoregress.- Ip
Protocol string The protocol. Can be
tcp,udp,icmp,greorall.- Nic
Type string Network type,
internetorintranet.- Output
File string - Policy string
Authorization policy. Can be either
acceptordrop.
- Group
Desc string The description of the security group that owns the rules.
- Group
Id string - Group
Name string The name of the security group that owns the rules.
- Id string
The provider-assigned unique ID for this managed resource.
- Rules
[]Get
Security Group Rules Rule A list of security group rules. Each element contains the following attributes:
- Direction string
Authorization direction,
ingressoregress.- Ip
Protocol string The protocol. Can be
tcp,udp,icmp,greorall.- Nic
Type string Network type,
internetorintranet.- Output
File string - Policy string
Authorization policy. Can be either
acceptordrop.
- group
Desc string The description of the security group that owns the rules.
- group
Id string - group
Name string The name of the security group that owns the rules.
- id string
The provider-assigned unique ID for this managed resource.
- rules
Get
Security Group Rules Rule[] A list of security group rules. Each element contains the following attributes:
- direction string
Authorization direction,
ingressoregress.- ip
Protocol string The protocol. Can be
tcp,udp,icmp,greorall.- nic
Type string Network type,
internetorintranet.- output
File string - policy string
Authorization policy. Can be either
acceptordrop.
- group_
desc str The description of the security group that owns the rules.
- group_
id str - group_
name str The name of the security group that owns the rules.
- id str
The provider-assigned unique ID for this managed resource.
- rules
List[Get
Security Group Rules Rule] A list of security group rules. Each element contains the following attributes:
- direction str
Authorization direction,
ingressoregress.- ip_
protocol str The protocol. Can be
tcp,udp,icmp,greorall.- nic_
type str Network type,
internetorintranet.- output_
file str - policy str
Authorization policy. Can be either
acceptordrop.
Supporting Types
GetSecurityGroupRulesRule
See the output API doc for this type.
See the output API doc for this type.
See the output API doc for this type.
- Description string
The description of the rule.
- Dest
Cidr stringIp Target IP address segment for egress authorization.
- Dest
Group stringId - Dest
Group stringOwner Account Alibaba Cloud account of the target security group.
- Direction string
Authorization direction. Valid values are:
ingressoregress.- Ip
Protocol string The IP protocol. Valid values are:
tcp,udp,icmp,greandall.- Nic
Type string Refers to the network type. Can be either
internetorintranet. The default value isinternet.- Policy string
Authorization policy. Can be either
acceptordrop. The default value isaccept.- Port
Range string The range of port numbers.
- Priority int
Rule priority.
- Source
Cidr stringIp Source IP address segment for ingress authorization.
- Source
Group stringId - Source
Group stringOwner Account Alibaba Cloud account of the source security group.
- Description string
The description of the rule.
- Dest
Cidr stringIp Target IP address segment for egress authorization.
- Dest
Group stringId - Dest
Group stringOwner Account Alibaba Cloud account of the target security group.
- Direction string
Authorization direction. Valid values are:
ingressoregress.- Ip
Protocol string The IP protocol. Valid values are:
tcp,udp,icmp,greandall.- Nic
Type string Refers to the network type. Can be either
internetorintranet. The default value isinternet.- Policy string
Authorization policy. Can be either
acceptordrop. The default value isaccept.- Port
Range string The range of port numbers.
- Priority int
Rule priority.
- Source
Cidr stringIp Source IP address segment for ingress authorization.
- Source
Group stringId - Source
Group stringOwner Account Alibaba Cloud account of the source security group.
- description string
The description of the rule.
- dest
Cidr stringIp Target IP address segment for egress authorization.
- dest
Group stringId - dest
Group stringOwner Account Alibaba Cloud account of the target security group.
- direction string
Authorization direction. Valid values are:
ingressoregress.- ip
Protocol string The IP protocol. Valid values are:
tcp,udp,icmp,greandall.- nic
Type string Refers to the network type. Can be either
internetorintranet. The default value isinternet.- policy string
Authorization policy. Can be either
acceptordrop. The default value isaccept.- port
Range string The range of port numbers.
- priority number
Rule priority.
- source
Cidr stringIp Source IP address segment for ingress authorization.
- source
Group stringId - source
Group stringOwner Account Alibaba Cloud account of the source security group.
- description str
The description of the rule.
- dest
Cidr strIp Target IP address segment for egress authorization.
- dest
Group strId - dest
Group strOwner Account Alibaba Cloud account of the target security group.
- direction str
Authorization direction. Valid values are:
ingressoregress.- ip_
protocol str The IP protocol. Valid values are:
tcp,udp,icmp,greandall.- nic_
type str Refers to the network type. Can be either
internetorintranet. The default value isinternet.- policy str
Authorization policy. Can be either
acceptordrop. The default value isaccept.- port_
range str The range of port numbers.
- priority float
Rule priority.
- source
Group strId - source_
cidr_ strip Source IP address segment for ingress authorization.
- source_
group_ strowner_ account Alibaba Cloud account of the source security group.
Package Details
- Repository
- https://github.com/pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.