List of usage examples for com.amazonaws.regions Region getRegion
public static Region getRegion(Regions region)
From source file:com.easarrive.quartz.aws.service.impl.AbstractCloudSearch4DocumentsService.java
License:Open Source License
public AbstractCloudSearch4DocumentsService(String regionName, String searchEndpoint, String docEndpoint, String idFieldName, String indexTimeFieldName) { Regions regions = Regions.fromName(regionName); Region region = Region.getRegion(regions); this.region = region; this.searchEndpoint = searchEndpoint; this.docEndpoint = docEndpoint; this.idFieldName = idFieldName; this.indexTimeFieldName = indexTimeFieldName; }
From source file:com.epam.dlab.automation.cloud.aws.AmazonHelper.java
License:Apache License
private static Region getRegion() { return Region.getRegion(Regions.fromName(ConfigPropertyValue.getAwsRegion())); }
From source file:com.erudika.para.iot.AWSIoTService.java
License:Apache License
protected AWSIotClient getClient() { if (iotClient != null) { return iotClient; }// ww w .j a v a 2 s . co m Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); iotClient = new AWSIotClient(new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)) .withRegion(region); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownClient(); } }); return iotClient; }
From source file:com.erudika.para.iot.AWSIoTService.java
License:Apache License
protected AWSIotDataClient getDataClient() { if (iotDataClient != null) { return iotDataClient; }//from w ww .j a va 2s . co m Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); iotDataClient = new AWSIotDataClient(new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)) .withRegion(region); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownDataClient(); } }); return iotDataClient; }
From source file:com.erudika.para.persistence.AWSDynamoUtils.java
License:Apache License
/** * Returns a client instance for AWS DynamoDB. * @return a client that talks to DynamoDB *//*from w w w . j a v a 2 s . c o m*/ public static AmazonDynamoDBClient getClient() { if (ddbClient != null) { return ddbClient; } if (Config.IN_PRODUCTION) { Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); ddbClient = new AmazonDynamoDBClient( new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)).withRegion(region); } else { ddbClient = new AmazonDynamoDBClient(new BasicAWSCredentials("local", "null")) .withEndpoint(LOCAL_ENDPOINT); } if (!existsTable(Config.APP_NAME_NS)) { createTable(Config.APP_NAME_NS); } ddb = new DynamoDB(ddbClient); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownClient(); } }); return ddbClient; }
From source file:com.erudika.para.queue.AWSQueueUtils.java
License:Apache License
/** * Returns a client instance for AWS SQS. * @return a client that talks to SQS/*ww w .j a v a 2 s . c o m*/ */ public static AmazonSQSClient getClient() { if (sqsClient != null) { return sqsClient; } if (Config.IN_PRODUCTION) { Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); sqsClient = new AmazonSQSClient(new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)) .withRegion(region); } else { sqsClient = new AmazonSQSClient(new BasicAWSCredentials("x", "x")).withEndpoint(LOCAL_ENDPOINT); } Para.addDestroyListener(new DestroyListener() { public void onDestroy() { sqsClient.shutdown(); } }); return sqsClient; }
From source file:com.erudika.para.storage.AWSFileStore.java
License:Apache License
/** * Creates a new instance based on the bucket provided. * @param bucket the name of the S3 bucket */// w ww.ja va 2 s.c o m public AWSFileStore(String bucket) { this.bucket = bucket; this.awsCredentials = new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY); Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); this.s3 = new AmazonS3Client(awsCredentials).withRegion(region); }
From source file:com.espressologic.aws.sqs.AmazonEmailService.java
License:Open Source License
/** * send email using credentials and region * * @param request//from w w w . j ava2 s . c om * @throws Exception */ public static void sendEmalRequest(SendEmailRequest request) throws Exception { try { System.out.println("Attempting to send an email through Amazon SES by using the AWS SDK for Java..."); /* * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). * * TransferManager manages a pool of threads, so we create a * single instance and share it throughout our application. */ createAWSCredentials(); // Instantiate an Amazon SES client, which will make the service call with the supplied AWS credentials. AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials); // Choose the AWS region of the Amazon SES endpoint you want to connect to. Note that your production // access status, sending limits, and Amazon SES identity-related settings are specific to a given // AWS region, so be sure to select an AWS region in which you set up Amazon SES. Here, we are using // the US East (N. Virginia) region. Examples of other regions that Amazon SES supports are US_WEST_2 // and EU_WEST_1. For a complete list, see http://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html Region REGION = Region.getRegion(getMyRegion()); client.setRegion(REGION); // Send the email. client.sendEmail(request); System.out.println("Email sent!"); } catch (Exception ex) { System.out.println("The email was not sent."); System.out.println("Error message: " + ex.getMessage()); throw ex; } }
From source file:com.eucalyptus.cloudformation.workflow.WorkflowClientManager.java
License:Open Source License
public static void start() throws Exception { final AmazonSimpleWorkflow simpleWorkflowClient; if (USE_AWS_SWF) { System.setProperty("com.amazonaws.sdk.disableCertChecking", "true"); final BasicAWSCredentials creds = new BasicAWSCredentials(AWS_ACCESS_KEY, AWS_SECRET_KEY); simpleWorkflowClient = new AmazonSimpleWorkflowClient(creds); simpleWorkflowClient.setRegion(Region.getRegion(Regions.US_EAST_1)); } else {//w ww. jav a 2 s . c o m simpleWorkflowClient = Config.buildClient( CloudFormationAWSCredentialsProvider.CloudFormationUserSupplier.INSTANCE, SWF_CLIENT_CONFIG); } workflowClient = new WorkflowClient(CloudFormation.class, simpleWorkflowClient, SWF_DOMAIN, SWF_TASKLIST, SWF_WORKFLOW_WORKER_CONFIG, SWF_ACTIVITY_WORKER_CONFIG); workflowClient.start(); }
From source file:com.example.kwang27.secmap.AmazonClientManager.java
License:Open Source License
private void initClients() { CognitoCachingCredentialsProvider credentials = new CognitoCachingCredentialsProvider(context, Constants.IDENTITY_POOL_ID, Regions.US_EAST_1); ddb = new AmazonDynamoDBClient(credentials); ddb.setRegion(Region.getRegion(Regions.US_WEST_2)); }