code: def fetchEC2InstanceDict(regionNickname=None):
      
      ec2Source = 'https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json'
      if regionNickname is None:
          regionNickname = 'us-west-2'
      region = EC2Regions[regionNickname]  # JSON uses verbose region names as keys
  
      ec2InstanceList = []
  
      # summon the API to grab the latest instance types/prices/specs
      response = requests.get(ec2Source)
      if response.ok:
          ec2InstanceList = parseEC2Json2List(jsontext=response.text, region=region)
  
      if ec2InstanceList:
          return dict((_.name, _) for _ in ec2InstanceList)
      else:
          from toil.lib import generatedEC2Lists as defaultEC2
          return dict((_.name, _) for _ in defaultEC2.ec2InstancesByRegion[regionNickname])
docs: Fetches EC2 instances types by region programmatically using the AWS pricing API.
  
      See: https://aws.amazon.com/blogs/aws/new-aws-price-list-api/
  
      :return: A dict of InstanceType objects, where the key is the string:
               aws instance name (example: 't2.micro'), and the value is an
               InstanceType object representing that aws instance name.