@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; }
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; }
/** * If no region is explicitly given and no region can be found from the {@link * AwsRegionProvider} implementation then the builder should fail to build clients. We mock the * provider to yield consistent results for the tests. */ @Test(expected = AmazonClientException.class) public void noRegionProvidedExplicitlyOrImplicitly_ThrowsException() { AwsRegionProvider mockRegionProvider = mock(AwsRegionProvider.class); when(mockRegionProvider.getRegion()).thenReturn(null); new ConcreteAsyncBuilder(mockRegionProvider).build(); }
/** * Customers may not need to explicitly configure a builder with a region if one can be found * from the {@link AwsRegionProvider} implementation. We mock the provider to yield consistent * results for the tests. */ @Test public void regionImplicitlyProvided_UsesRegionToConstructEndpoint() { AwsRegionProvider mockRegionProvider = mock(AwsRegionProvider.class); when(mockRegionProvider.getRegion()).thenReturn("ap-southeast-2"); final URI actualUri = new ConcreteAsyncBuilder(mockRegionProvider).build().getEndpoint(); assertEquals(URI.create("https://mockprefix.ap-southeast-2.amazonaws.com"), actualUri); }
@SdkTestInternalApi AmazonS3Builder(SdkFunction<AmazonS3ClientParamsWrapper, AmazonS3> clientFactory, ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { super(clientConfigFactory, regionProvider); this.clientFactory = clientFactory; }
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); }
@SdkTestInternalApi protected AwsSyncClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { super(clientConfigFactory, regionProvider); }
@SdkTestInternalApi protected AwsAsyncClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { super(clientConfigFactory, regionProvider); }
@SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { this.clientConfigFactory = clientConfigFactory; this.regionProvider = regionProvider; }
private ConcreteAsyncBuilder(AwsRegionProvider mockRegionProvider) { super(new MockClientConfigurationFactory(), mockRegionProvider); }
@SdkTestInternalApi AmazonS3ClientBuilder(SdkFunction<AmazonS3ClientParamsWrapper, AmazonS3> clientFactory, ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { super(clientFactory, clientConfigFactory, regionProvider); }
public CloudClient(AmazonEC2 ec2Client, AwsRegionProvider regionProvider) { this.ec2Client = ec2Client; this.regionProvider = regionProvider; }