How to use authorize_security_group_egress method in localstack

Best Python code snippet using localstack_python

test_vpc_nat_scenario.py

Source:test_vpc_nat_scenario.py Github

copy

Full Screen

...215 sg = self.ctx.web_security_group216 status = self.vpc_client.revoke_security_group_egress(217 sg.id, "-1", cidr_ip="0.0.0.0/0")218 self.assertTrue(status)219 status = self.vpc_client.authorize_security_group_egress(220 sg.id, "tcp", 1433, 1433,221 src_group_id=self.ctx.db_security_group.id)222 self.assertTrue(status)223 status = self.vpc_client.authorize_security_group_egress(224 sg.id, "tcp", 3306, 3306,225 src_group_id=self.ctx.db_security_group.id)226 self.assertTrue(status)227 # NOTE(ft): especially for connectivity test228 status = self.vpc_client.authorize_security_group_egress(229 sg.id, "tcp", 80, 80, cidr_ip="0.0.0.0/0")230 self.assertTrue(status)231 # NOTE(ft): especially for connectivity test232 status = self.vpc_client.authorize_security_group_egress(233 sg.id, "tcp", 22, 22,234 src_group_id=self.ctx.db_security_group.id)235 self.assertTrue(status)236 status = self.vpc_client.authorize_security_group(237 group_id=sg.id, ip_protocol="tcp", from_port=80, to_port=80,238 cidr_ip="0.0.0.0/0")239 self.assertTrue(status)240 status = self.vpc_client.authorize_security_group(241 group_id=sg.id, ip_protocol="tcp", from_port=443, to_port=443,242 cidr_ip="0.0.0.0/0")243 self.assertTrue(status)244 status = self.vpc_client.authorize_security_group(245 group_id=sg.id, ip_protocol="tcp", from_port=22, to_port=22,246 cidr_ip=str(self.test_client_cidr))247 self.assertTrue(status)248 status = self.vpc_client.authorize_security_group(249 group_id=sg.id, ip_protocol="tcp", from_port=3389,250 to_port=3389, cidr_ip=str(self.test_client_cidr))251 self.assertTrue(status)252 sg = self.ctx.nat_security_group253 status = self.vpc_client.revoke_security_group_egress(254 sg.id, "-1", cidr_ip="0.0.0.0/0")255 self.assertTrue(status)256 status = self.vpc_client.authorize_security_group_egress(257 sg.id, "tcp", 80, 80, cidr_ip="0.0.0.0/0")258 self.assertTrue(status)259 status = self.vpc_client.authorize_security_group_egress(260 sg.id, "tcp", 443, 443, cidr_ip="0.0.0.0/0")261 self.assertTrue(status)262 status = self.vpc_client.authorize_security_group_egress(263 sg.id, "tcp", 53, 53, cidr_ip="0.0.0.0/0")264 self.assertTrue(status)265 status = self.vpc_client.authorize_security_group_egress(266 sg.id, "udp", 53, 53, cidr_ip="0.0.0.0/0")267 self.assertTrue(status)268 status = self.vpc_client.authorize_security_group(269 group_id=sg.id, ip_protocol="tcp", from_port=53,270 to_port=53, cidr_ip="0.0.0.0/0")271 self.assertTrue(status)272 status = self.vpc_client.authorize_security_group(273 group_id=sg.id, ip_protocol="udp", from_port=53,274 to_port=53, cidr_ip="0.0.0.0/0")275 self.assertTrue(status)276 status = self.vpc_client.authorize_security_group(277 group_id=sg.id, ip_protocol="tcp", from_port=80, to_port=80,278 cidr_ip=str(self.db_subnet))279 self.assertTrue(status)280 status = self.vpc_client.authorize_security_group(281 group_id=sg.id, ip_protocol="tcp", from_port=443, to_port=443,282 cidr_ip=str(self.db_subnet))283 self.assertTrue(status)284 status = self.vpc_client.authorize_security_group(285 group_id=sg.id, ip_protocol="tcp", from_port=22, to_port=22,286 cidr_ip=str(self.test_client_cidr))287 self.assertTrue(status)288 sg = self.ctx.db_security_group289 status = self.vpc_client.revoke_security_group_egress(290 sg.id, "-1", cidr_ip="0.0.0.0/0")291 self.assertTrue(status)292 status = self.vpc_client.authorize_security_group_egress(293 sg.id, "tcp", 80, 80, cidr_ip="0.0.0.0/0")294 self.assertTrue(status)295 status = self.vpc_client.authorize_security_group_egress(296 sg.id, "tcp", 443, 443, cidr_ip="0.0.0.0/0")297 self.assertTrue(status)298 status = self.vpc_client.authorize_security_group_egress(299 sg.id, "tcp", 53, 53, cidr_ip="0.0.0.0/0")300 self.assertTrue(status)301 status = self.vpc_client.authorize_security_group_egress(302 sg.id, "udp", 53, 53, cidr_ip="0.0.0.0/0")303 self.assertTrue(status)304 status = self.vpc_client.authorize_security_group(305 group_id=sg.id, ip_protocol="tcp",306 from_port=1433,307 to_port=1433,308 src_security_group_group_id=self.ctx.web_security_group.id)309 self.assertTrue(status)310 status = self.vpc_client.authorize_security_group(311 group_id=sg.id, ip_protocol="tcp",312 from_port=3306,313 to_port=3306,314 src_security_group_group_id=self.ctx.web_security_group.id)315 self.assertTrue(status)...

Full Screen

Full Screen

ec2.py

Source:ec2.py Github

copy

Full Screen

...23 GroupName=group.name,24 Description=group.description25 )['GroupId']26 # by default if we have a vpc sg we will allow all out bound27 client.authorize_security_group_egress(28 GroupId=group_id,29 IpProtocol='tcp',30 FromPort=0,31 ToPort=65535,32 CidrIp='0.0.0.0/0'33 )34 return group_id35@sts_conn('ec2')36@rate_limited()37def delete_group(group, account_number=None, region=None, assume_role=None, client=None):38 client.delete_security_group(39 GroupId=group.aws_group_id40 )41@sts_conn('ec2')42@rate_limited()43def authorize_rule(rule, group, account_number=None, region=None, assume_role=None, client=None):44 if rule.direction == 'egress':45 # response = client.authorize_security_group_egress()46 raise BotorException("Modifying egress rules is not yet supported by Grouper")47 else:48 if rule.cidr:49 client.authorize_security_group_ingress(50 GroupId=group.aws_group_id,51 IpProtocol=rule.protocol,52 FromPort=rule.from_port,53 ToPort=rule.to_port,54 CidrIp=rule.cidr55 )56 else:57 client.authorize_security_group_ingress(58 GroupId=group.aws_group_id,59 IpProtocol=rule.protocol,60 FromPort=rule.from_port,61 ToPort=rule.to_port,62 SourceSecurityGroupName=rule.source_security_group.name,63 # SourceSecurityGroupOwnerId=rule.source_security_group.account.aws_account_id64 )65@sts_conn('ec2')66@rate_limited()67def revoke_rule(rule, group, account_number=None, region=None, assume_role=None, client=None):68 if rule.direction == 'egress':69 # response = client.authorize_security_group_egress()70 raise BotorException("Modifying egress rules is not yet supported by Grouper")71 else:72 client.revoke_security_group_ingress(73 GroupId=group.aws_group_id,74 IpProtocol=rule.protocol,75 FromPort=rule.from_port,76 ToPort=rule.to_port,77 CidrIp=rule.cidr,78 )79@sts_conn('ec2')80@rate_limited()81def add_groups_to_instance(instance_id, groups, account_number=None, region=None, assume_role=None, client=None):82 client.modify_instance_attribute(InstanceId=instance_id, Groups=groups)83@sts_conn('ec2')84@rate_limited()85def describe_instances(**kwargs):86 return kwargs.pop('client').get_paginator('describe_instances').paginate()87@sts_conn('ec2')88@rate_limited()89def describe_security_groups(**kwargs):90 return kwargs.pop('client').describe_security_groups(**kwargs)91@sts_conn('ec2')92@rate_limited()93def create_security_group(**kwargs):94 return kwargs.pop('client').create_security_group(**kwargs)95@sts_conn('ec2')96@rate_limited()97def authorize_security_group_ingress(**kwargs):98 return kwargs.pop('client').authorize_security_group_ingress(**kwargs)99@sts_conn('ec2')100@rate_limited()101def authorize_security_group_egress(**kwargs):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful