Switch the AWS region

        > use us-west-1
        > use us-east-1
540259
def do_use(self, region):
        
        if self._local_endpoint is not None:
            host, port = self._local_endpoint  # pylint: disable=W0633
            self.engine.connect(
                region, session=self.session, host=host, port=port, is_secure=False
            )
        else:
            self.engine.connect(region, session=self.session)
831845
def _validate_region(self):
        """"""
        if not self.region:
            raise GCECloudException(
                'Zone is required for GCE cloud framework: '
                'Example: us-west1-a'
            )

        try:
            zone = self.compute_driver.ex_get_zone(self.region)
        except Exception:
            zone = None

        if not zone:
            raise GCECloudException(
                '{region} is not a valid GCE zone. '
                'Example: us-west1-a'.format(
                    region=self.region
                )
            )
641996
function( url, wc, options, callback ) {
	if ( typeof options === 'function' ) {
		callback = options;
		options = null;
	}
	options = options || {};
	executeSvn( [ 'relocate', url, wc ], options, callback );
}
1275517
def from_store_name(bucket_name, region=None):
    
    # Late-bind `region` for the sake of tests that inject the
    # AWS_REGION environment variable.
    if region is None:
        region = os.getenv('AWS_REGION')

    mostly_ok = _is_mostly_subdomain_compatible(bucket_name)

    if not mostly_ok:
        return CallingInfo(
            bucket_name=bucket_name,
            region=region,
            calling_format=connection.OrdinaryCallingFormat,
            ordinary_endpoint=must_resolve(region))
    else:
        if '.' in bucket_name:
            # The bucket_name might have been DNS compatible, but once
            # dots are involved TLS certificate validations will
            # certainly fail even if that's the case.
            return CallingInfo(
                bucket_name=bucket_name,
                calling_format=connection.OrdinaryCallingFormat,
                region=region,
                ordinary_endpoint=must_resolve(region))
        else:
            # If the bucket follows naming rules and has no dots in
            # the name, SubdomainCallingFormat can be used, with TLS,
            # world-wide.
            return CallingInfo(
                bucket_name=bucket_name,
                calling_format=connection.SubdomainCallingFormat,
                region=region,
                ordinary_endpoint=None)

    assert False
2339
function updateReqBucketRegion(request, region) {
    var httpRequest = request.httpRequest;
    if (typeof region === 'string' && region.length) {
      httpRequest.region = region;
    }
    if (!httpRequest.endpoint.host.match(/s3(?!-accelerate).*\.amazonaws\.com$/)) {
      return;
    }
    var service = request.service;
    var s3Config = service.config;
    var s3BucketEndpoint = s3Config.s3BucketEndpoint;
    if (s3BucketEndpoint) {
      delete s3Config.s3BucketEndpoint;
    }
    var newConfig = AWS.util.copy(s3Config);
    delete newConfig.endpoint;
    newConfig.region = httpRequest.region;

    httpRequest.endpoint = (new AWS.S3(newConfig)).endpoint;
    service.populateURI(request);
    s3Config.s3BucketEndpoint = s3BucketEndpoint;
    httpRequest.headers.Host = httpRequest.endpoint.host;

    if (request._asm.currentState === 'validate') {
      request.removeListener('build', service.populateURI);
      request.addListener('build', service.removeVirtualHostedBucketFromPath);
    }
  }
11788
def convert_aws_args(aws_args):
    """"""
    if not isinstance(aws_args, dict):
        raise errors.InvalidConfiguration(
            'Elastic DocManager config option "aws" must be a dict'
        )
    old_session_kwargs = dict(
        region="region_name",
        access_id="aws_access_key_id",
        secret_key="aws_secret_access_key",
    )
    new_kwargs = {}
    for arg in aws_args:
        if arg in old_session_kwargs:
            new_kwargs[old_session_kwargs[arg]] = aws_args[arg]
        else:
            new_kwargs[arg] = aws_args[arg]
    return new_kwargs
1329235
def get_bucket_region(self, bucket) -> str:
        
        region = self.s3_client.get_bucket_location(Bucket=bucket)["LocationConstraint"]
        return 'us-east-1' if region is None else region
629974
def allow_access_to_instance(self, _, ip_address):
        '''  '''
        if not self.connect_to_aws_rds():
            return False
        try:
            conn = boto.ec2.connect_to_region(
                self.region,
                aws_access_key_id=self.aws_access_key_id,
                aws_secret_access_key=self.aws_secret_access_key
            )
            sgs = conn.get_all_security_groups('default')
            default_sg = sgs[0]
            default_sg.authorize(ip_protocol='tcp', from_port=3306,
                                 to_port=3306, cidr_ip=str(ip_address)+'/32')
        except EC2ResponseError, exception:
            if exception.error_code == "InvalidPermission.Duplicate":
                return True  # ok it already exists
            else:
                return False
        else:
            return True
288479
def __get_location(conn, vm_):
    '''
    
    '''
    location = config.get_cloud_config_value(
        'location', vm_, __opts__)
    return conn.ex_get_zone(location)
562347
def _set_account_info(self):
        
        if 'AWS_DEFAULT_REGION' in os.environ:
            logger.debug('Connecting to IAM with region_name=%s',
                         os.environ['AWS_DEFAULT_REGION'])
            kwargs = {'region_name': os.environ['AWS_DEFAULT_REGION']}
        elif 'AWS_REGION' in os.environ:
            logger.debug('Connecting to IAM with region_name=%s',
                         os.environ['AWS_REGION'])
            kwargs = {'region_name': os.environ['AWS_REGION']}
        else:
            logger.debug('Connecting to IAM without specified region')
            kwargs = {}
        conn = client('iam', **kwargs)
        self.aws_account_id = conn.get_user()['User']['Arn'].split(':')[4]
        # region
        conn = client('lambda', **kwargs)
        self.aws_region = conn._client_config.region_name
        logger.info('Found AWS account ID as %s; region: %s',
                    self.aws_account_id, self.aws_region)
30332
def get_signer_hostname():
    
    region = os.getenv("AWS_REGION", "")
    region = region if region and region in SUPPORTED_REGIONS else "us-west-2"
    return "signer.{region}.iopipe.com".format(region=region)
991955
URI resolveServiceEndpoint(String bucketName) {

        if (getSignerRegion() != null || isSignerOverridden()) return endpoint;

        final String regionStr = fetchRegionFromCache(bucketName);
        final com.amazonaws.regions.Region region = RegionUtils.getRegion(regionStr);

        if (region == null) {
            log.warn("Region information for "
                    + regionStr
                    + " is not available. Please upgrade to latest version of AWS Java SDK");
        }

        return region != null
                ? RuntimeHttpUtils.toUri(region.getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration)
                : endpoint;
    }
254501
function setCliConfiguration() {
  return yargs
    .usage('usage: $0 [options] <aws-elasticsearch-cluster-endpoint>')
    .option('h', {
      alias: 'host',
      default: HOST || '127.0.0.1',
      demand: false,
      describe: 'Host IP Address',
      type: 'string',
    })
    .option('p', {
      alias: 'port',
      default: PORT || 9200,
      demand: false,
      describe: 'Host Port',
      type: 'number',
    })
    .option('r', {
      alias: 'region',
      default: REGION || 'us-west-2',
      demand: false,
      describe: 'AWS region',
      type: 'string',
    })
    .option('e', {
      alias: 'endpoint',
      default: ENDPOINT,
      demand: true,
      describe: 'AWS Elasticsearch Endpoint',
      type: 'string',
    })
    .option('c', {
      alias: 'profile',
      default: AWS_PROFILE || 'default',
      demand: false,
      describe: 'AWS Credentials Profile',
      type: 'string',
    })
    .option('d', {
      alias: 'debug',
      default: DEBUG || false,
      demand: false,
      describe: 'Provides debug logging',
      type: 'boolean',
    })
    .help()
    .version()
    .strict()
}
1326923
def DistributeKeyToRegions(src_region, dst_regions, private_keypair,
                           aws_id, aws_secret):
  
  private_key = RSA.importKey(private_keypair.material)
  public_key_material = PrivateToPublicOpenSSH(private_key,
                                               private_keypair.name)
  for dst_region in dst_regions:
    if dst_region == src_region:
      continue
    logging.info( 'distributing key %s to region %s' % (private_keypair.name,
                                                        dst_region))
    dst_region_ec2 = CreateTestedEc2Connection(aws_id, aws_secret,
                                                    dst_region)
    try:
      dst_region_ec2.delete_key_pair(private_keypair.name)
    except:
      raise
    dst_region_ec2.import_key_pair(private_keypair.name, public_key_material)
  return
708812
def avail_locations(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_locations function must be called with '
            '-f or --function, or with the --list-locations option'
        )

    ret = {}

    params = {'Action': 'DescribeRegions'}
    result = aws.query(params,
                       location=get_location(),
                       provider=get_provider(),
                       opts=__opts__,
                       sigver='4')

    for region in result:
        ret[region['regionName']] = {
            'name': region['regionName'],
            'endpoint': region['regionEndpoint'],
        }

    return ret
722928
def _set_distro(self):
        """"""
        if self.distro_name == 'sles':
            self.distro = SLES()
        elif self.distro_name == 'opensuse_leap':
            self.distro = openSUSE_Leap()
        else:
            raise IpaCloudException(
                'Distribution: %s, not supported.' % self.distro_name
            )
406759
def apply_system_defaults
      if    @region.nil? && @zone.nil?
        @region, @zone = Rudy::DEFAULT_REGION, Rudy::DEFAULT_ZONE
      elsif @region.nil?
        @region = @zone.to_s.gsub(/[a-z]$/, '').to_sym
      elsif @zone.nil?
        @zone = "#{@region}b".to_sym
      end
      
      @environment ||= Rudy::DEFAULT_ENVIRONMENT
      @role ||= Rudy::DEFAULT_ROLE
      @localhost ||= Rudy.sysinfo.hostname || 'localhost'
      @auto = false if @auto.nil?
    end