Java 类com.amazonaws.regions.DefaultAwsRegionProviderChain 实例源码

项目:aem-orchestrator    文件:AwsConfig.java   
@Bean
public Region awsRegion() {
    Region region;
    if(regionString != null && !regionString.isEmpty()) {
        region = RegionUtils.getRegion(regionString);
    } else {
        AwsRegionProvider regionProvider = new DefaultAwsRegionProviderChain();
        region = RegionUtils.getRegion(regionProvider.getRegion());
    }

    if(region == null) {
        throw new BeanInitializationException("Unable to determine AWS region");
    }

    return region;
}
项目:zipkin    文件:ZipkinElasticsearchAwsStorageAutoConfiguration.java   
@Bean String region(ZipkinElasticsearchStorageProperties es,
    ZipkinElasticsearchAwsStorageProperties aws) {
  List<String> hosts = es.getHosts();
  String domain = aws.getDomain();
  if (hosts != null && domain != null) {
    log.warning(
        format("Expected exactly one of hosts or domain: instead saw hosts '%s' and domain '%s'."
            + " Ignoring hosts and proceeding to look for domain. Either unset ES_HOSTS or "
            + "ES_AWS_DOMAIN to suppress this message.", hosts, domain));
  }

  if (aws.getRegion() != null) {
    return aws.getRegion();
  } else if (domain != null) {
    return new DefaultAwsRegionProviderChain().getRegion();
  } else {
    return regionFromAwsUrls(hosts).get();
  }
}
项目:cfnassist    文件:FacadeFactory.java   
public AwsFacade createFacade() throws MissingArgumentException, CfnAssistException, InterruptedException {     
    if (awsFacade==null) {
        init();
        SNSEventSource eventSource = new SNSEventSource(snsClient, sqsClient);
        MonitorStackEvents monitor;
        if (snsMonitoring) {    
            monitor = new SNSMonitor(eventSource, cfnRepository);
        } else {
            monitor = new PollingStackMonitor(cfnRepository);
        }

        monitor.init();
           AwsRegionProvider regionProvider = new DefaultAwsRegionProviderChain();
           awsFacade = new AwsFacade(monitor, cfnRepository, vpcRepository, elbRepository,
                cloudRepository, notificationSender, identityProvider);
    }   
    return awsFacade;   
}
项目:cfnassist    文件:TestPictureGeneration.java   
@Before
public void beforeEachTestRuns() {
    AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
    AmazonEC2 ec2Client = EnvironmentSetupForTests.createEC2Client();
    AmazonElasticLoadBalancing awsElbClient = EnvironmentSetupForTests.createELBClient();
    AmazonCloudFormation cfnClient = EnvironmentSetupForTests.createCFNClient();
    AmazonRDS awsRdsClient = EnvironmentSetupForTests.createRDSClient();

    CloudClient cloudClient = new CloudClient(ec2Client, new DefaultAwsRegionProviderChain());
    LoadBalancerClient elbClient = new LoadBalancerClient(awsElbClient);
    VpcRepository vpcRepository = new VpcRepository(cloudClient);

    CloudFormationClient cloudFormationClient = new CloudFormationClient(cfnClient);
    cloudRepository = new CloudRepository(cloudClient);
    ResourceRepository cfnRepository = new CfnRepository(cloudFormationClient, cloudRepository, "CfnAssist");

    elbRepository = new ELBRepository(elbClient, vpcRepository, cfnRepository);
    rdsClient = new RDSClient(awsRdsClient);
}
项目:cfnassist    文件:TestCommandLineStackOperations.java   
@Before
public void beforeEveryTestRun() {
    vpcRepository = new VpcRepository(new CloudClient(ec2Client, new DefaultAwsRegionProviderChain()));
    altProjectAndEnv = EnvironmentSetupForTests.getAltProjectAndEnv();
    EnvironmentSetupForTests.getMainProjectAndEnv();

    altEnvVPC = EnvironmentSetupForTests.findAltVpc(vpcRepository); 
    deletesStacks = new DeletesStacks(cfnClient);
    deletesStacks.ifPresent(EnvironmentSetupForTests.TEMPORARY_STACK)
        .ifPresent("CfnAssistTest01createSubnet")
        .ifPresent("CfnAssistTest02createAcls")
        .ifPresent("CfnAssistTestsimpleStack")
        .ifPresent("CfnAssistTestsubnet")
        .ifPresent("CfnAssist876TestelbAndInstance")
           .ifPresent("CfnAssistTestsimpleStackWithAZ");
    deletesStacks.act();
    testName = test.getMethodName();
}
项目:cfnassist    文件:TestCommandLineS3Operations.java   
@Before
public void beforeEveryTestRun() {

    deleteTestKeysFromBucket();

    vpcRepository = new VpcRepository(new CloudClient(ec2Client, new DefaultAwsRegionProviderChain()));
    projectAndEnv = EnvironmentSetupForTests.getMainProjectAndEnv();

    deletesStacks = new DeletesStacks(cfnClient);
    deletesStacks.ifPresent(EnvironmentSetupForTests.TEMPORARY_STACK)
        .ifPresent("CfnAssistTest01createSubnet")
        .ifPresent("CfnAssistTest02createAcls")
        .ifPresent("CfnAssistTestsimpleStack");
    deletesStacks.act();
    testName = test.getMethodName();
}
项目:strongbox    文件:CustomRegionProviderChain.java   
private Optional<Region> getRegionFromMetadata() {
    try {
        Region resolvedRegion = null;
        if (EC2MetadataUtils.getInstanceInfo() != null) {
            if (EC2MetadataUtils.getInstanceInfo().getRegion() != null) {
                resolvedRegion = Region.fromName(EC2MetadataUtils.getInstanceInfo().getRegion());
            } else { // fallback to provider chain if region is not exposed
                resolvedRegion = Region.fromName(new DefaultAwsRegionProviderChain().getRegion());
            }
        }
        return Optional.ofNullable(resolvedRegion);
    } catch (SdkClientException e) {
        return Optional.empty();
    }
}
项目:nexus-public    文件:AmazonS3Factory.java   
private String defaultRegion() {
  try {
    return new DefaultAwsRegionProviderChain().getRegion();
  }
  catch (SdkClientException e) {
    String region = Regions.DEFAULT_REGION.getName();
    log.warn("Default AWS region not configured, using {}", region, e);
    return region;
  }
}
项目:cfnassist    文件:FacadeFactory.java   
private void createProviders() {
    loadBalancerClient = new LoadBalancerClient(elbClient);
       AwsRegionProvider regionProvider = new DefaultAwsRegionProviderChain();
       cloudClient = new CloudClient(ec2Client, regionProvider);
    formationClient = new CloudFormationClient(cfnClient);
    datastoreClient = new RDSClient(rdsClient);
    notificationSender = new SNSNotificationSender(snsClient);
    identityProvider = new IdentityProvider(iamClient);
}
项目:cfnassist    文件:TestCloudFormationClient.java   
@BeforeClass
public static void onceBeforeClassRuns() {
    DefaultAWSCredentialsProviderChain credentialsProvider = new DefaultAWSCredentialsProviderChain();
    ec2Client = EnvironmentSetupForTests.createEC2Client();
    regionProvider = new DefaultAwsRegionProviderChain();
    vpcRepository = new VpcRepository(new CloudClient(ec2Client, regionProvider));
    cfnClient = EnvironmentSetupForTests.createCFNClient();
    AmazonSNS snsClient = EnvironmentSetupForTests.createSNSClient();
    AmazonSQS sqsClient = EnvironmentSetupForTests.createSQSClient();
    snsNotifProvider = new SNSEventSource(snsClient, sqsClient);

    new DeletesStacks(cfnClient).ifPresent("queryStackTest").
        ifPresent("createStackTest").
        ifPresent("createIAMStackTest").act();
}
项目:cfnassist    文件:TestManageSecGroups.java   
@Before
public void beforeEachTestRuns() {  
    client = new CloudClient(ec2Client, new DefaultAwsRegionProviderChain());

    deleteGroupIfPresent();

    CreateSecurityGroupRequest createRequest = new CreateSecurityGroupRequest().
            withDescription("test group").
            withGroupName(GROUP_NAME);
    CreateSecurityGroupResult result = ec2Client.createSecurityGroup(createRequest);
    groupId = result.getGroupId();
}
项目:cfnassist    文件:TestCloudClient.java   
@Test
public void shouldGetAvailabilityZones() {
    String regionName = new DefaultAwsRegionProviderChain().getRegion();
    Map<String, AvailabilityZone> zones = cloudClient.getAvailabilityZones();

    assertEquals(3, zones.size());
    zones.forEach((name, zone) -> assertEquals(regionName, zone.getRegionName()));
       assertTrue(zones.containsKey("a"));
       assertTrue(zones.containsKey("b"));
}
项目:aws-cf-templates    文件:AAWSTest.java   
protected final String getRegion() {
    return new DefaultAwsRegionProviderChain().getRegion();
}
项目:cfnassist    文件:TestCloudClient.java   
@Before
public void beforeEachTestIsRun() {
    ec2Client = EnvironmentSetupForTests.createEC2Client();
    cloudClient = new CloudClient(ec2Client, new DefaultAwsRegionProviderChain());
}
项目:cfnassist    文件:TestCommandLineVPCoperations.java   
@Before
public void beforeEveryTestRun() {
    VpcRepository vpcRepository = new VpcRepository(new CloudClient(ec2Client, new DefaultAwsRegionProviderChain()));
    altEnvVPC = EnvironmentSetupForTests.findAltVpc(vpcRepository); 
}