How to use create_network_acl_entry method in localstack

Best Python code snippet using localstack_python

Provision_SubnetNacl.py

Source:Provision_SubnetNacl.py Github

copy

Full Screen

...38 39 #network-aclname240 41 ######### Inbound Rules ##########42 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=1, protocol=6, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )43 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=2, protocol=17, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )44 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=10, protocol=6, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )45 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=11, protocol=17, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )46 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=20, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=49152, port_range_to=65535 )47 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=21, protocol=17, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=32768, port_range_to=61000 )48 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=30, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=80, port_range_to=80 )49 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=31, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=443, port_range_to=443 )50 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=40, protocol=1, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )51 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=41, protocol=1, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )52 53 ######### Outbound Rules ##########54 vpc.create_network_acl_entry(network_acl_id=nacl2, rule_number=1, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )55else:56 print "Network ACL " + network_aclname2 + " already exists"57if len(get_nacl(name=network_aclname4, region=region)) == 0:58 nacl4 = create_nacl(vpc_id=vpc_id, region=region, network_aclname=network_aclname4)59 60 ########################## Create Network Acls entries for Network ACL created above ######################61 62 #network-aclname463 64 ######### Inbound Rules ##########65 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=1, protocol=6, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )66 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=2, protocol=17, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )67 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=10, protocol=6, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )68 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=11, protocol=17, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )69 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=20, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=49152, port_range_to=65535 )70 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=21, protocol=17, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=32768, port_range_to=61000 )71 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=30, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=80, port_range_to=80 )72 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=40, protocol=1, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )73 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=41, protocol=1, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )74 75 ######### Outbound Rules ##########76 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=1, protocol=6, rule_action='Allow', cidr_block='172.31.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )77 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=2, protocol=17, rule_action='Allow', cidr_block='172.31.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )78 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=10, protocol=6, rule_action='Allow', cidr_block='10.133.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )79 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=11, protocol=17, rule_action='Allow', cidr_block='10.133.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )80 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=20, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=1, port_range_from=80, port_range_to=80 )81 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=21, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=1, port_range_from=443, port_range_to=443 )82 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=30, protocol=1, rule_action='Allow', cidr_block='10.133.0.0/16', egress=1, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )83 vpc.create_network_acl_entry(network_acl_id=nacl4, rule_number=40, protocol=1, rule_action='Allow', cidr_block='172.31.0.0/16', egress=1, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )84else:85 print "Network ACL " + network_aclname4 + " already exists"86 87if len(get_nacl(name=network_aclname1, region=region)) == 0:88 nacl1 = create_nacl(vpc_id=vpc_id, region=region, network_aclname=network_aclname1)89 90 #network-aclname191 92 ######### Inbound Rules ##########93 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=1, protocol=6, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )94 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=2, protocol=17, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )95 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=10, protocol=6, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )96 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=11, protocol=17, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )97 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=20, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=49152, port_range_to=65535 )98 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=21, protocol=17, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=32768, port_range_to=61000 )99 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=30, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=80, port_range_to=80 )100 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=40, protocol=1, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )101 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=41, protocol=1, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )102 103 104 ######### Outbound Rules ##########105 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=1, protocol=6, rule_action='Allow', cidr_block='172.31.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )106 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=2, protocol=17, rule_action='Allow', cidr_block='172.31.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )107 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=10, protocol=6, rule_action='Allow', cidr_block='10.133.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )108 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=11, protocol=17, rule_action='Allow', cidr_block='10.133.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )109 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=20, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=1, port_range_from=80, port_range_to=80 )110 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=21, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=1, port_range_from=443, port_range_to=443 )111 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=30, protocol=1, rule_action='Allow', cidr_block='10.133.0.0/16', egress=1, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )112 vpc.create_network_acl_entry(network_acl_id=nacl1, rule_number=40, protocol=1, rule_action='Allow', cidr_block='172.31.0.0/16', egress=1, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )113else:114 print "Network ACL " + network_aclname1 + " already exists"115if len(get_nacl(name=network_aclname3, region=region)) == 0:116 nacl3 = create_nacl(vpc_id=vpc_id, region=region, network_aclname=network_aclname3)117 118 #network-aclname3119 120 ######### Inbound Rules ##########121 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=1, protocol=6, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )122 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=2, protocol=17, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )123 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=10, protocol=6, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )124 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=11, protocol=17, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=65535 )125 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=20, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=49152, port_range_to=65535 )126 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=21, protocol=17, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=32768, port_range_to=61000 )127 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=30, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=80, port_range_to=80 )128 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=31, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/0', egress=0, port_range_from=443, port_range_to=443 )129 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=40, protocol=1, rule_action='Allow', cidr_block='10.133.0.0/16', egress=0, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )130 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=41, protocol=1, rule_action='Allow', cidr_block='172.31.0.0/16', egress=0, port_range_from=0, port_range_to=0, icmp_code=-1, icmp_type=-1 )131 132 133 ######### Outbound Rules ##########134 vpc.create_network_acl_entry(network_acl_id=nacl3, rule_number=1, protocol=6, rule_action='Allow', cidr_block='0.0.0.0/16', egress=1, port_range_from=0, port_range_to=65535 )135 ###############################################################################################################136else:137 print "Network ACL " + network_aclname3 + " already exists"138#Create subnet139if len(get_subnet(name=subnet1_name, region=region)) == 0:140 subnet1 = create_subnet(vpc_id=vpc_id, cidr_block=cidr_block1, availability_zone=availability_zone1, subnet_name=subnet1_name, region=region)141 vpc.associate_network_acl(nacl1, subnet1)142else:143 print "Subnet " + subnet1_name + " already exists"144 145if len(get_subnet(name=subnet2_name, region=region)) == 0:146 subnet2 = create_subnet(vpc_id=vpc_id, cidr_block=cidr_block2, availability_zone=availability_zone2, subnet_name=subnet2_name, region=region)147 vpc.associate_network_acl(nacl2, subnet2)148else:...

Full Screen

Full Screen

all_region_kill_switch.py

Source:all_region_kill_switch.py Github

copy

Full Screen

...14 if nacls:15 for nacl in nacls:16 print('{}'.format(nacl['NetworkAclId']))17 # Block all Inbound traffic18 client.create_network_acl_entry(19 DryRun=True,20 CidrBlock='0.0.0.0/0',21 Egress=False,22 Protocol='-1',23 RuleAction='deny',24 RuleNumber=1,25 NetworkAclId=nacl['NetworkAclId'] 26 )27 client.create_network_acl_entry(28 DryRun=True,29 Ipv6CidrBlock='::0/0',30 Egress=False,31 Protocol='-1',32 RuleAction='deny',33 RuleNumber=2,34 NetworkAclId=nacl['NetworkAclId'] 35 )36 # Block all Outbound traffic37 client.create_network_acl_entry(38 DryRun=True,39 CidrBlock='0.0.0.0/0',40 Egress=True,41 Protocol='-1',42 RuleAction='deny',43 RuleNumber=1,44 NetworkAclId=nacl['NetworkAclId'] 45 )46 client.create_network_acl_entry(47 DryRun=True,48 Ipv6CidrBlock='::0/0',49 Egress=True,50 Protocol='-1',51 RuleAction='deny',52 RuleNumber=2,53 NetworkAclId=nacl['NetworkAclId'] 54 )55#make them verify a random number because it will block traffic for all VPCs in all regions for that account.56rannum=randint(1000, 9999)57print("Please enter the following number to continue {}: ".format(rannum))58data = input()59if int(data) != rannum:60 print('Error: verification number does not match')...

Full Screen

Full Screen

region_kill_switch.py

Source:region_kill_switch.py Github

copy

Full Screen

...14 if nacls:15 for nacl in nacls:16 print('{}'.format(nacl['NetworkAclId']))17 # Block all Inbound traffic18 client.create_network_acl_entry(19 DryRun=True,20 CidrBlock='0.0.0.0/0',21 Egress=False,22 Protocol='-1',23 RuleAction='deny',24 RuleNumber=1,25 NetworkAclId=nacl['NetworkAclId'] 26 )27 client.create_network_acl_entry(28 DryRun=True,29 Ipv6CidrBlock='::0/0',30 Egress=False,31 Protocol='-1',32 RuleAction='deny',33 RuleNumber=2,34 NetworkAclId=nacl['NetworkAclId'] 35 )36 # Block all Outbound traffic37 client.create_network_acl_entry(38 DryRun=True,39 CidrBlock='0.0.0.0/0',40 Egress=True,41 Protocol='-1',42 RuleAction='deny',43 RuleNumber=1,44 NetworkAclId=nacl['NetworkAclId'] 45 )46 client.create_network_acl_entry(47 DryRun=True,48 Ipv6CidrBlock='::0/0',49 Egress=True,50 Protocol='-1',51 RuleAction='deny',52 RuleNumber=2,53 NetworkAclId=nacl['NetworkAclId'] 54 )55#make them verify a random number because it will block traffic for all VPCs in that region.56rannum=randint(1000, 9999)57print("Please enter the following number to continue {}: ".format(rannum))58data = input()59if int(data) != rannum:60 print('Error: verification number does not match')...

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