Skip to main content

security_group_rules

Creates, updates, deletes, gets or lists a security_group_rules resource.

Overview

Namesecurity_group_rules
TypeResource
Idaws.ec2.security_group_rules

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
cidr_ipv_4stringThe IPv4 CIDR range.
cidr_ipv_6stringThe IPv6 CIDR range.
descriptionstringThe security group rule description.
from_portintegerIf the protocol is TCP or UDP, this is the start of the port range. If the protocol is ICMP or ICMPv6, this is the ICMP type or -1 (all ICMP types).
group_idstringThe ID of the security group.
group_owner_idstringThe ID of the Amazon Web Services account that owns the security group.
ip_protocolstringThe IP protocol name (tcp, udp, icmp, icmpv6) or number (see Protocol Numbers). Use -1 to specify all protocols.
is_egressbooleanIndicates whether the security group rule is an outbound rule.
prefix_list_idstringThe ID of the prefix list.
referenced_group_infostringDescribes the security group that is referenced in the rule.
security_group_rule_arnstringThe ARN of the security group rule.
security_group_rule_idstringThe ID of the security group rule.
tagsstringThe tags applied to the security group rule.
to_portintegerIf the protocol is TCP or UDP, this is the end of the port range. If the protocol is ICMP or ICMPv6, this is the ICMP code or -1 (all ICMP codes). If the start port is -1 (all ICMP types), then the end port must be -1 (all ICMP codes).

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_security_group_rulesselectregionFilter, SecurityGroupRuleId, DryRun, NextToken, MaxResultsDescribes one or more of your security group rules.
modify_security_group_rulesupdateGroupId, SecurityGroupRule, regionDryRunModifies the rules of a security group.
update_security_group_rule_descriptions_egressupdateregionDryRun, GroupId, GroupName, IpPermissions, SecurityGroupRuleDescriptionUpdates the description of an egress (outbound) security group rule. You can replace an existing description, or add a description to a rule that did not have one previously. You can remove a description for a security group rule by omitting the description parameter in the request.
update_security_group_rule_descriptions_ingressexecregionDryRun, GroupId, GroupName, IpPermissions, SecurityGroupRuleDescriptionUpdates the description of an ingress (inbound) security group rule. You can replace an existing description, or add a description to a rule that did not have one previously. You can remove a description for a security group rule by omitting the description parameter in the request.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
GroupIdstringThe ID of the security group.
SecurityGroupRulearrayInformation about the security group properties to update.
regionstringAWS region (default: us-east-1)
DryRunbooleanChecks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
FilterarrayOne or more filters. group-id - The ID of the security group. security-group-rule-id - The ID of the security group rule. tag:<key> - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value TeamA, specify tag:Owner for the filter name and TeamA for the filter value.
GroupIdstringThe ID of the security group. You must specify either the security group ID or the security group name in the request. For security groups in a nondefault VPC, you must specify the security group ID.
GroupNamestring[Default VPC] The name of the security group. You must specify either the security group ID or the security group name. For security groups in a nondefault VPC, you must specify the security group ID.
IpPermissionsarrayThe IP permissions for the security group rule. You must specify either IP permissions or a description.
MaxResultsintegerThe maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. This value can be between 5 and 1000. If this parameter is not specified, then all items are returned. For more information, see Pagination.
NextTokenstringThe token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.
SecurityGroupRuleDescriptionarrayThe description for the ingress security group rules. You must specify either a description or IP permissions.
SecurityGroupRuleIdarrayThe IDs of the security group rules.

SELECT examples

Describes one or more of your security group rules.

SELECT
cidr_ipv_4,
cidr_ipv_6,
description,
from_port,
group_id,
group_owner_id,
ip_protocol,
is_egress,
prefix_list_id,
referenced_group_info,
security_group_rule_arn,
security_group_rule_id,
tags,
to_port
FROM aws.ec2.security_group_rules
WHERE region = '{{ region }}' -- required
AND Filter = '{{ Filter }}'
AND SecurityGroupRuleId = '{{ SecurityGroupRuleId }}'
AND DryRun = '{{ DryRun }}'
AND NextToken = '{{ NextToken }}'
AND MaxResults = '{{ MaxResults }}'
;

UPDATE examples

Modifies the rules of a security group.

UPDATE aws.ec2.security_group_rules
SET
-- No updatable properties
WHERE
GroupId = '{{ GroupId }}' --required
AND SecurityGroupRule = '{{ SecurityGroupRule }}' --required
AND region = '{{ region }}' --required
AND DryRun = {{ DryRun}}
RETURNING
return;

Lifecycle Methods

Updates the description of an ingress (inbound) security group rule. You can replace an existing description, or add a description to a rule that did not have one previously. You can remove a description for a security group rule by omitting the description parameter in the request.

EXEC aws.ec2.security_group_rules.update_security_group_rule_descriptions_ingress
@region='{{ region }}' --required,
@DryRun={{ DryRun }},
@GroupId='{{ GroupId }}',
@GroupName='{{ GroupName }}',
@IpPermissions='{{ IpPermissions }}',
@SecurityGroupRuleDescription='{{ SecurityGroupRuleDescription }}'
;