You can use a Ansible Filter Plugin. 

I have a repo with all of my filter plugins. Line 8 has the function you 
need.

def get_account_id(region):
    client = boto3.client('iam', region_name=region)
    try:
        account_id = client.list_users()['Users'][0]['Arn'].split(':')[4]
        return account_id
    except Exception:
        raise errors.AnsibleFilterError(
            "Failed to retrieve account id"
        )



https://github.com/linuxdynasty/ld-ansible-filters/blob/master/filter_plugins/aws.py#L8

On Tuesday, May 17, 2016 at 8:16:26 PM UTC-7, Erick Barros wrote:
>
> Hi guys,
>
> does anyone have a good option to get the my aws account id using Ansible ?
>
> Thanks !
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e5d91ca1-80bf-4652-aecd-8ea0feb77d9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to