authorize_security_group_egress
¶
authorize_security_group_egress(
*,
config_overrides: Optional[EC2ClientConfig] = None,
tag_specifications: Optional[TagSpecificationList] = None,
dry_run: Optional[Boolean] = None,
group_id: Optional[SecurityGroupId] = None,
source_security_group_name: Optional[String] = None,
source_security_group_owner_id: Optional[String] = None,
ip_protocol: Optional[String] = None,
from_port: Optional[Integer] = None,
to_port: Optional[Integer] = None,
cidr_ip: Optional[String] = None,
ip_permissions: Optional[IpPermissionList] = None,
) -> AuthorizeSecurityGroupEgressResult
Adds the specified outbound (egress) rules to a security group.
An outbound rule permits instances to send traffic to the specified IPv4 or IPv6 address ranges, the IP address ranges specified by a prefix list, or the instances that are associated with a source security group. For more information, see Security group rules.
You must specify exactly one of the following destinations: an IPv4 or IPv6 address range, a prefix list, or a security group. You must specify a protocol for each rule (for example, TCP). If the protocol is TCP or UDP, you must also specify a port or port range. If the protocol is ICMP or ICMPv6, you must also specify the ICMP type and code.
Rule changes are propagated to instances associated with the security group as quickly as possible. However, a small delay might occur.
For examples of rules that you can add to security groups for specific access scenarios, see Security group rules for different use cases in the Amazon EC2 User Guide.
For information about security group quotas, see Amazon VPC quotas in the Amazon VPC User Guide.
Parameters:
-
tag_specifications(Optional[TagSpecificationList], default:None) –The tags applied to the security group rule.
-
dry_run(Optional[Boolean], default:None) –Checks 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 isUnauthorizedOperation. -
group_id(Optional[SecurityGroupId], default:None) –The ID of the security group.
-
source_security_group_name(Optional[String], default:None) –Not supported. Use IP permissions instead.
-
source_security_group_owner_id(Optional[String], default:None) –Not supported. Use IP permissions instead.
-
ip_protocol(Optional[String], default:None) –Not supported. Use IP permissions instead.
-
from_port(Optional[Integer], default:None) –Not supported. Use IP permissions instead.
-
to_port(Optional[Integer], default:None) –Not supported. Use IP permissions instead.
-
cidr_ip(Optional[String], default:None) –Not supported. Use IP permissions instead.
-
ip_permissions(Optional[IpPermissionList], default:None) –The permissions for the security group rules.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To add a rule that allows outbound traffic to a specific address range This example adds a rule that grants access to the specified address ranges on TCP port 80.
>>> client.authorize_security_group_egress(group_id='sg-1a2b3c4d', ip_permissions=[{'IpProtocol': 'tcp', 'FromPort': 80, 'ToPort': 80, 'IpRanges': [{'CidrIp': '10.0.0.0/16'}]}])
To add a rule that allows outbound traffic to a specific security group
This example adds a rule that grants access to the specified security group on TCP port 80.
>>> client.authorize_security_group_egress(group_id='sg-1a2b3c4d', ip_permissions=[{'IpProtocol': 'tcp', 'FromPort': 80, 'ToPort': 80, 'UserIdGroupPairs': [{'GroupId': 'sg-4b51a32f'}]}])
Source code in docs_src/capo_ec2/_services/ec2.py
5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 | |