Boto3 でのお話。
NatGateway を短時間に同じタグ名で立ち上げていて、前のものは削除しているのだが describe すると削除の状態で残ってしまっているので、タグでフィルターしても複数がひっかかってしまっている。
現在、available のものを選択して削除したい、ということで、次の関数に渡すために AllocationId が必要。
Dictionary を紐解くために、以下のコードとした。
for i in range(10):
nat_gateway_id=response1['NatGateways'][i]['NatGatewayId']
public_ip=response1['NatGateways'][i]['NatGatewayAddresses'][0]['PublicIp']
allocation_id=response1['NatGateways'][i]['NatGatewayAddresses'][0]['AllocationId']
state=response1['NatGateways'][i]['State']
print('allocation_id:' + allocation_id)
print('state:' + state)
if state == 'available':
break