Best Python code snippet using localstack_python
network.py
Source:network.py
1import boto32import botocore3import json4import config5import res.utils as utils6import res.glob as glob7# =======================================================================================================================8#9# Supported services : API Gateway (simple), VPC (in 'compute' module), Route 53, Cloud Front10# Unsupported services : Direct Connect11#12# =======================================================================================================================13# ------------------------------------------------------------------------14#15# API Gateway (simple) 16#17# ------------------------------------------------------------------------18def get_apigateway_inventory(oId):19 """20 Returns API Gateway inventory21 :param oId: ownerId (AWS account)22 :type oId: string23 :return: API Gateway inventory24 :rtype: json25 ..note:: http://boto3.readthedocs.io/en/latest/reference/services/apigateway.html26 ..todo:: add --> plans, api keys, custom domain names, client certificates, vpc links27 """28 29 return glob.get_inventory(30 ownerId = oId,31 aws_service = "apigateway", 32 aws_region = "all", 33 function_name = "get_rest_apis", 34 key_get = "items",35 pagination = True36 )37# ------------------------------------------------------------------------38#39# CloudFront40#41# ------------------------------------------------------------------------42def get_cloudfront_inventory(oId):43 """44 Returns cloudfront inventory45 :param oId: ownerId (AWS account)46 :type oId: string47 :return: Cloudfront inventory48 :rtype: json49 ..note:: http://boto3.readthedocs.io/en/latest/reference/services/cloudfront.html50 """51 52 return glob.get_inventory(53 ownerId = oId,54 aws_service = "cloudfront", 55 aws_region = "all", 56 function_name = "list_distributions", 57 key_get = "Items",58 pagination = True59 )60# ------------------------------------------------------------------------61#62# Route 5363#64# ------------------------------------------------------------------------65def get_route53_inventory(oId):66 """67 Returns route 53 inventory, partial.68 Traffic policies are not detailed because the detail function needs 2 arguments.69 :param oId: ownerId (AWS account)70 :type oId: string71 :return: route 53 inventory72 :rtype: json73 ..note:: http://boto3.readthedocs.io/en/latest/reference/services/route53.html74 """75 76 inventory = {}77 78 inventory['zones'] = glob.get_inventory(79 ownerId = oId,80 aws_service = "route53", 81 aws_region = "global", 82 function_name = "list_hosted_zones_by_name", 83 key_get = "HostedZones",84 detail_function = "list_resource_record_sets", 85 join_key = "Id", 86 detail_join_key = "HostedZoneId", 87 detail_get_key = "ResourceRecordSets",88 pagination = True89 )90 inventory['traffic-policies'] = glob.get_inventory(91 ownerId = oId,92 aws_service = "route53", 93 aws_region = "global", 94 function_name = "list_traffic_policies", 95 key_get = "TrafficPolicySummaries",96 pagination = True97 )98 inventory['domains'] = glob.get_inventory(99 ownerId = oId,100 aws_service = "route53domains", 101 aws_region = "all", 102 function_name = "list_domains", 103 key_get = "Domains"104 )105 return inventory106# ------------------------------------------------------------------------107#108# Elastic Load Balancer109#110# ------------------------------------------------------------------------111def get_elb_inventory(oId):112 """113 Returns ELB inventory114 :param oId: ownerId (AWS account)115 :type oId: string116 :return: ELB inventory117 :rtype: json118 ..note:: http://boto3.readthedocs.io/en/latest/reference/services/elb.html119 """120 return glob.get_inventory(121 ownerId = oId,122 aws_service = "elb",123 aws_region = "all",124 function_name = "describe_load_balancers",125 key_get = "LoadBalancerDescriptions",126 pagination = True127 )128# ------------------------------------------------------------------------129#130# Elastic Load Balancer v2131#132# ------------------------------------------------------------------------133def get_elbv2_inventory(oId):134 """135 Returns ELBv2 inventory136 :param oId: ownerId (AWS account)137 :type oId: string138 :return: ELBv2 inventory139 :rtype: json140 ..note:: http://boto3.readthedocs.io/en/latest/reference/services/elbv2.html141 """142 143 return glob.get_inventory(144 ownerId = oId,145 aws_service = "elbv2", 146 aws_region = "all", 147 function_name = "describe_load_balancers", 148 key_get = "LoadBalancers",149 pagination = True150 )151#152# Hey, doc: we're in a module!153#154if (__name__ == '__main__'):...
aws_index.py
Source:aws_index.py
...36 #return (url_list)37 def route53_scean(self,user_id,user_pass):38 aws_client = boto3.client('route53',aws_access_key_id=user_id, aws_secret_access_key=user_pass)39# print(dir(aws_client))40# print (aws_client.list_traffic_policies())41 def location_s3_object_lookup(self,user_id,user_pass):42 aws_client = boto3.client('s3',aws_access_key_id=user_id, aws_secret_access_key=user_pass)43 s3_list = aws_client.list_buckets()44 #print (s3_list)45 for bucket in s3_list['Buckets']:46 #print(bucket)47 location_location_location = aws_client.get_bucket_location(Bucket=bucket['Name'])48 if not 'eu-west-' in location_location_location['LocationConstraint']:49 self.msg = self.msg + ("\n\n --- The bucket " + bucket['Name'] + " is in the zone " + location_location_location['LocationConstraint'])50 def ec2_zone_check(self,user_id,user_pass):51 aws_client = boto3.client('ec2',aws_access_key_id=user_id, aws_secret_access_key=user_pass)52 availability_zones = aws_client.describe_availability_zones()53 for zone in availability_zones['AvailabilityZones']:54 if not 'eu-west-' in zone['RegionName']:...
Route53Namespace_fire.py
Source:Route53Namespace_fire.py
...57 """58 profile = request.args.get("profile")59 route53=boto3.client('route53', region_name=str(db.child('profiles').child(str(profile)).get().val()['region']), aws_access_key_id=str(db.child('profiles').child(str(profile)).get().val()['access_key']), aws_secret_access_key=str(db.child('profiles').child(str(profile)).get().val()['secret_access_key']))60 61 trafficpolicies=route53.list_traffic_policies()62 63 return str(trafficpolicies)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!