Re: [ansible-project] Re: Getting aws account id

2016-05-17 Thread Erick Vitor de Barros
Thanks Allen, I'll give it a try !

On Wed, May 18, 2016 at 3:32 PM, Allen Sanabria 
wrote:

> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> 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.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKz6g-16v1ohDrJDsh4b7gpfqdx1tRW2L374EgWwLbuFmvQypg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Getting aws account id

2016-05-17 Thread Allen Sanabria
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
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.