@Test public void kms() { RegionUtils.initialize(); String[] regions = { "us-east-1", "us-west-1", "us-west-2", "ap-northeast-1", "ap-southeast-1", "ap-southeast-2", "sa-east-1", "eu-west-1", "eu-central-1" }; for (String region : regions) { assertEquals( region, RegionUtils.getRegionByEndpoint("kms." + region + ".amazonaws.com/bla").getName()); assertEquals( region, RegionUtils.getRegionByEndpoint("https://kms." + region + ".amazonaws.com").getName()); assertEquals( "kms." + region + ".amazonaws.com", RegionUtils.getRegion(region).getServiceEndpoint("kms")); } }
public static Region getRegion(String regionName) { if (StringUtils.isNotEmpty(regionName)) { return RegionUtils.getRegion(regionName); } else { return Region.getRegion(Regions.US_EAST_1); } }
@Inject public AWSCucumberStepdefs(AmazonWebServiceClient client) { this.client = client; this.client.setRegion(RegionUtils.getRegion("us-east-1")); Class<?> httpClientClass = Classes.childClassOf(AmazonWebServiceClient.class, this.client); this.packageName = httpClientClass.getPackage().getName(); }
public Region getRegion() { if (null != regionObj) { return regionObj; } regionObj = RegionUtils.getRegion(regionName); Validate.notNull(regionObj, "Invalid region: " + regionName); return regionObj; }
/** * Creates a new StreamSource. * * @param config Configuration to determine which stream to put records to and get {@link * AWSCredentialsProvider} * @param inputFile File containing record data to emit on each line * @param loopOverStreamSource Loop over the stream source to continually put records */ public StreamSource( KinesisConnectorConfiguration config, String inputFile, boolean loopOverStreamSource) { this.config = config; this.inputFile = inputFile; this.loopOverInputFile = loopOverStreamSource; this.objectMapper = new ObjectMapper(); kinesisClient = new AmazonKinesisClient(config.AWS_CREDENTIALS_PROVIDER); kinesisClient.setRegion(RegionUtils.getRegion(config.REGION_NAME)); if (config.KINESIS_ENDPOINT != null) { kinesisClient.setEndpoint(config.KINESIS_ENDPOINT); } KinesisUtils.createInputStream(config); }
@Override @JsonProperty public Region getRegion() { return RegionUtils.getRegion(region); }
private void checkIsRegionNameValid(String regionNameToCheck) { if (regionNameToCheck != null && RegionUtils.getRegion(regionNameToCheck) == null) { throw new IllegalArgumentException("The specified region name is not valid"); } }