Python Forum
short code to list AWS regions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
short code to list AWS regions
#1
this is some short code (148 bytes on a NL text system, 150 bytes on a CRLF system) to list the names of AWS regions. to use this you need:
* an AWS account (free for one year)
* set up your credentials for boto3 or botocore to use
* installed boto3 or botocore (in PyPI so pip can do it)

import botocore.session
print('\n'.join(r['RegionName']for r in botocore.session.get_session().create_client('ec2').describe_regions()['Regions']))
(if you already have boto3 then you already have botocore)
this is only tested on Ubuntu Linux but it should also work on other OSes.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020