Hi@akhtar,
An EC2 instance is a virtual server in Amazon's Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure. You can connect the AWS using some python SDK as well. To describe the security group, you can use the below script.
import boto3
from botocore.exceptions import ClientError
ec2 = boto3.client('ec2')
try:
response = ec2.describe_security_groups(GroupIds=['SECURITY_GROUP_ID'])
print(response)
except ClientError as e:
print(e)