To get list of Amazon regions and availability zones

Hi team,

I would like to get a list of Amazon regions and availability zones using ansible . Please let me know if this can be done using ansible

Regards,
Shobha

`
Shobha,

I don't think there's a module for that yet, but you can use thecommand` module to call the aws cli. It’ll give you a JSON string that you can parse with a from_json filter:

`

  • name: “Get AWS regions json”
    command: aws ec2 describe-regions
    register: describe_regions

  • name: “Parse AWS regions into aws_regions”
    set_fact:
    aws_regions: “{{ describe_regions.stdout | from_json }}”

  • debug: var=aws_regions
    `
    (untested)

You should be able to do something similar for the Availability Zones too.