1)에 :BOTO 내가 boto3 코드로 BOTO에서이를 구현하려면 어떻게 Boto3 기능 구현
conn = boto.connect_ec2() # boto way
sgs = conn.get_all_security_groups() # boto way
for sg in sgs:
if len(sg.instances()) == 0:
print(sg.name, sg.id, len(sg.instances()))
위의 코드는 기본적으로 연결없는 경우 모든 보안 그룹을 인쇄합니다. duct.sh()
모듈을 사용
2)이 개개의 명령
command = 'aws ec2 describe-instances --filters "Name=instance.group-id,Values=' + sg.id + '\" --query \'Reservations[*].Instances[*].[InstanceId,Tags[?Key==`Name`] | [0].Value]\' --output json'
은 '나를위한 코드 작성'과 매우 유사하므로 boto 3 doc (http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Client.describe_security_groups) 및 2 확인 http://boto3.readthedocs.io/en/latest/reference/services /ec2.html#EC2.Client.describe_instances –
질문의 두 번째 부분에서 실제로 무엇을 묻고 있습니까? 서로 관련이없는 경우 별도의 질문을 만드십시오. –