I made image of source instance and now i had to clone new instance, Thus i hardcoded the security group name of source instance in target instance creation. now I want it to be dynamically. Below is my code:
ec2 = boto3.resource('ec2',region_name='region')
instance = ec2.create_instances( ImageId=image, InstanceType='t2.micro', KeyName='keyName', SecurityGroups=['sgr-ssh-http-public'], MaxCount=1, MinCount=1 )