Skip to content

Instantly share code, notes, and snippets.

@Ashex
Last active August 29, 2015 14:26
Show Gist options
  • Save Ashex/e5a9a6e37a30e59043ae to your computer and use it in GitHub Desktop.
Save Ashex/e5a9a6e37a30e59043ae to your computer and use it in GitHub Desktop.
Accepts a yaml file containing a list of regions as an argument and does stuff with each.
#!/usr/bin/env python
import argparse, yaml
def region(regiondict):
for i in regiondict:
print(i)
def main():
parser = argparse.ArgumentParser(description='Do stuff with this region')
parser.add_argument('-r', '--region', help='Yaml file containing a bunch of regions')
args = parser.parse_args()
region_file = open(args.region, 'r')
region_dict = yaml.safe_load(region_file)
region(region_dict['region'])
if __name__ == "__main__":
main()
@Ashex
Copy link
Author

Ashex commented Jul 29, 2015

region_list.yml

region:
    - us-east-1
    - us-west-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment