Sets the S3 prefix for a CloudTrail Trail

        Args:
            region (`str`): Name of the AWS region
            name (`str`): Name of the CloudTrail Trail

        Returns:
            `None`
10308
def set_s3_prefix(self, region, name):
        
        ct = self.session.client('cloudtrail', region_name=region)
        ct.update_trail(Name=name, S3KeyPrefix=self.account.account_name)

        auditlog(
            event='cloudtrail.set_s3_prefix',
            actor=self.ns,
            data={
                'account': self.account.account_name,
                'region': region
            }
        )
        self.log.info('Updated S3KeyPrefix to {0} for {0}/{1}'.format(
            self.account.account_name,
            region
        ))
368728
def validate_trail_settings(self, ct, aws_region, trail):
        
        self.log.debug('Validating trail {}/{}/{}'.format(
            self.account.account_name,
            aws_region,
            trail['Name']
        ))
        status = ct.get_trail_status(Name=trail['Name'])
        if not status['IsLogging']:
            self.log.warning('Logging is disabled for {}/{}/{}'.format(
                self.account.account_name,
                aws_region,
                trail['Name']
            ))
            self.start_logging(aws_region, trail['Name'])

        if 'SnsTopicName' not in trail or not trail['SnsTopicName']:
            self.log.warning('SNS Notifications not enabled for {}/{}/{}'.format(
                self.account.account_name,
                aws_region,
                trail['Name']
            ))
            self.create_sns_topic(aws_region)
            self.enable_sns_notification(aws_region, trail['Name'])

        if not self.validate_sns_topic_subscription(aws_region):
            self.log.warning(
                'SNS Notification configured but not subscribed for {}/{}/{}'.format(
                    self.account.account_name,
                    aws_region,
                    trail['Name']
                )
            )
            self.subscribe_sns_topic_to_sqs(aws_region)

        if trail['S3BucketName'] != self.bucket_name:
            self.log.warning('CloudTrail is logging to an incorrect bucket for {}/{}/{}'.format(
                self.account.account_name,
                trail['S3BucketName'],
                trail['Name']
            ))
            self.set_s3_bucket(aws_region, trail['Name'], self.bucket_name)

        if not trail.get('S3KeyPrefix') or trail['S3KeyPrefix'] != self.account.account_name:
            self.log.warning('Missing or incorrect S3KeyPrefix for {}/{}/{}'.format(
                self.account.account_name,
                aws_region,
                trail['Name']
            ))
            self.set_s3_prefix(aws_region, trail['Name'])
694725
def region(region)
      if(region.to_s == 'us')
        config['api_host'] = US_API_HOST
      elsif(region.to_s == 'eu')
        config['api_host'] = EU_API_HOST
      else
        raise "Region Unknown"
      end
    end
325095
def set_prefix(self, elt, pyobj):
        '''
        '''
        if isinstance(pyobj, tuple):
            namespaceURI,localName = pyobj
            self.prefix = elt.getPrefix(namespaceURI)
813025
def destroy_s3_event(app, env, region):
    

    # TODO: how do we know which bucket to process if triggers dict is empty?
    # Maybe list buckets and see which has notification to that lambda defined?
    # TODO: buckets should be named the same as apps, what if one app has multiple buckets?
    # bucket = rules.get('bucket')
    generated = get_details(app=app, env=env)

    bucket = generated.s3_app_bucket()

    session = boto3.Session(profile_name=env, region_name=region)
    s3_client = session.client('s3')

    config = {}

    s3_client.put_bucket_notification_configuration(Bucket=bucket, NotificationConfiguration=config)
    LOG.debug("Deleted Lambda S3 notification")

    return True
506510
def _get_host(self, region):
        
        if 'us-east-1' in region:
            return 's3.amazonaws.com'
        elif region in AWS_REGIONS:
            return 's3-%s.amazonaws.com' % region
        elif region and not REGION_RE.findall(region):
            raise ImproperlyConfigured('AWS_REGION improperly configured!')
        # can be full host or empty string, default region
        return  region
365750
def generate_arn(
        service, resource, partition='aws',
        region=None, account_id=None, resource_type=None, separator='/'):
    
    if region and region in REGION_PARTITION_MAP:
        partition = REGION_PARTITION_MAP[region]
    if service == 's3':
        region = ''
    arn = 'arn:%s:%s:%s:%s:' % (
        partition, service, region if region else '', account_id if account_id else '')
    if resource_type:
        arn = arn + '%s%s%s' % (resource_type, separator, resource)
    else:
        arn = arn + resource
    return arn
124348
public String getAmazonRegion(String endpoint) {
        if (isBlank(endpoint)) {
            return DEFAULT_AMAZON_REGION;
        }
        final Pattern pattern = Pattern.compile("(https://)?(.+)?\\.(.+)\\."+AMAZON_HOSTNAME+"(\\.cn)?");
        final Matcher matcher = pattern.matcher(endpoint);
        if (matcher.find()) {
            return matcher.group(3);
        }
        return DEFAULT_AMAZON_REGION;
    }
1062777
def s3(ctx, bucket_name, data_file, region):
    """"""
    if not ctx.data_file:
        ctx.data_file = data_file

    if not ctx.bucket_name:
        ctx.bucket_name = bucket_name

    if not ctx.region:
        ctx.region = region

    ctx.type = 's3'
859779
public void setRegionNames(java.util.Collection<String> regionNames) {
        if (regionNames == null) {
            this.regionNames = null;
            return;
        }

        this.regionNames = new com.amazonaws.internal.SdkInternalList<String>(regionNames);
    }
603753
def emit_metadata_for_region_py(self, region, region_filename, module_prefix):
        """"""
        terrobj = self.territory[region]
        with open(region_filename, "w") as outfile:
            prnt(_REGION_METADATA_PROLOG % {'region': terrobj.identifier(), 'module': module_prefix}, file=outfile)
            prnt("PHONE_METADATA_%s = %s" % (terrobj.identifier(), terrobj), file=outfile)
447725
def subscribe_sns_topic_to_sqs(self, region):
        
        sns = self.session.resource('sns', region_name=region)
        topic = sns.Topic('arn:aws:sns:{}:{}:{}'.format(region, self.account.account_number, self.topic_name))

        topic.subscribe(Protocol='sqs', Endpoint=self.sqs_queue)

        auditlog(
            event='cloudtrail.subscribe_sns_topic_to_sqs',
            actor=self.ns,
            data={
                'account': self.account.account_name,
                'region': region
            }
        )

        return topic.attributes['TopicArn']
403338
def _initialize(self, boto_session, sagemaker_client, sagemaker_runtime_client):
        """"""

        self.boto_session = boto_session or boto3.Session()
        self._region_name = self.boto_session.region_name

        if self._region_name is None:
            raise ValueError('Must setup local AWS configuration with a region supported by SageMaker.')

        self.sagemaker_client = LocalSagemakerClient(self)
        self.sagemaker_runtime_client = LocalSagemakerRuntimeClient(self.config)
        self.local_mode = True
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);
    }
  }
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;
    }
713088
def get_zones(region, auth_kwargs):
    
    ec2_conn = boto.ec2.connect_to_region(region, **auth_kwargs)
    return [zone.name for zone in ec2_conn.get_all_zones()]
645821
def delete_key_pair(region, pair_name)
      kp = client(region).describe_key_pairs(:key_names => [pair_name]).key_pairs.first
      unless kp.nil?
        @logger.debug("aws-sdk: delete key pair in region: #{region}")
        client(region).delete_key_pair(:key_name => pair_name)
      end
    rescue Aws::EC2::Errors::InvalidKeyPairNotFound
      nil
    end