Feb-23-2018, 12:46 PM
(This post was last modified: Feb-23-2018, 12:46 PM by onenessboy.)
(Feb-23-2018, 11:58 AM)buran Wrote: You construct the Message out of the loop, so it has info only for last Instances (why plural by the way?) and last tag_name
I guess when print, you print to screen you do so from within the loop
msg_list = [] for reservation in desc['Reservations']: for instance in reservation['Instances']: public_ip_address = instance.get('PublicIpAddress', "-") or '-' private_ip_address = instance.get('PrivateIpAddress', "-") or '-' public_dns_name = instance.get('PublicDnsName', "-") or '-' private_dns_name = instance.get('PrivateDnsName', "-") or '-' status = instance['State']['Name'] for tag in instance['Tags']: if tag['Key'] == 'Name': tag_name = tag["Value"] break msg_text = '{} is {}'.format(tag_name, status) msg_list.append(msg_text) MESSAGE = {'text': '\n'.join(msg_list)}Note that the problem still valid for ip addresses - you don't store them anywhere, so out of the loop you will have only last values

Beautiful...it works like charm now :) I see both messages in Slack...
How can I just print OK if status is running if other status then its Failed.. within the loop it self ?
Thank you Buran..Much gratitude, Hope to become expert like you soon :)