Java Code Examples for com.amazonaws.regions.Regions#US_EAST_1
The following examples show how to use
com.amazonaws.regions.Regions#US_EAST_1 .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConvertService.java From alexa-meets-polly with Apache License 2.0 | 7 votes |
public static AmazonS3 getS3Client(final String region, final String roleArn) { final Regions awsRegion = StringUtils.isNullOrEmpty(region) ? Regions.US_EAST_1 : Regions.fromName(region); if (StringUtils.isNullOrEmpty(roleArn)) { return AmazonS3ClientBuilder.standard().withRegion(awsRegion).build(); } else { final AssumeRoleRequest assumeRole = new AssumeRoleRequest().withRoleArn(roleArn).withRoleSessionName("io-klerch-mp3-converter"); final AWSSecurityTokenService sts = AWSSecurityTokenServiceClientBuilder.standard().withRegion(awsRegion).build(); final Credentials credentials = sts.assumeRole(assumeRole).getCredentials(); final BasicSessionCredentials sessionCredentials = new BasicSessionCredentials( credentials.getAccessKeyId(), credentials.getSecretAccessKey(), credentials.getSessionToken()); return AmazonS3ClientBuilder.standard().withRegion(awsRegion).withCredentials(new AWSStaticCredentialsProvider(sessionCredentials)).build(); } }
Example 2
Source File: S3Service.java From hypergraphql with Apache License 2.0 | 5 votes |
Regions extractRegion(final URI uri) { final String regionString = uri.getHost().split("\\.")[0]; switch(regionString.toUpperCase()) { case ("S3"): return Regions.US_EAST_1; default: final String regionPart = regionString.substring(regionString.indexOf("-") + 1); return Regions.fromName(regionPart); } }
Example 3
Source File: AWSClientManager.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
public static void init(Context context) { provider = new CognitoCachingCredentialsProvider(context, AWS_ACCOUNT_ID, COGNITO_POOL_ID, COGNTIO_ROLE_UNAUTH, COGNITO_ROLE_AUTH, Regions.US_EAST_1); //initialize the Cognito Sync Client //initialize the Other Clients manager = new TransferManager(provider); analytics = MobileAnalyticsManager.getOrCreateInstance(context, "App_ID_Here", Regions.US_EAST_1, provider); }
Example 4
Source File: StepFunctionsSample.java From aws-doc-sdk-examples with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). * * It is possible to use another profile with: * credentialsProvider = new ProfileCredentialsProvider("your-profile") */ ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider(); try { credentialsProvider.getCredentials(); } catch (Exception e) { throw new AmazonClientException( "Cannot load the credentials from the credential profiles " + "file. Please make sure that your credentials file is " + "at the correct location (~/.aws/credentials), and is " + "in valid format.", e); } Regions region = Regions.US_EAST_1; AWSStepFunctions sfnClient = AWSStepFunctionsClientBuilder.standard() .withCredentials(credentialsProvider) .withRegion(region) .build(); System.out.println("==========================================="); System.out.println("Getting Started with Amazon Step Functions"); System.out.println("===========================================\n"); try { System.out.println("Listing state machines"); ListStateMachinesResult listStateMachinesResult = sfnClient. listStateMachines(new ListStateMachinesRequest()); List<StateMachineListItem> stateMachines = listStateMachinesResult .getStateMachines(); System.out.println("State machines count: " + stateMachines.size()); if (!stateMachines.isEmpty()) { stateMachines.forEach(sm -> { System.out.println("\t- Name: " + sm.getName()); System.out.println("\t- Arn: " + sm.getStateMachineArn()); ListExecutionsRequest listRequest = new ListExecutionsRequest().withStateMachineArn(sm .getStateMachineArn()); ListExecutionsResult listExecutionsResult = sfnClient .listExecutions(listRequest); List<ExecutionListItem> executions = listExecutionsResult .getExecutions(); System.out.println("\t- Total: " + executions.size()); executions.forEach(ex -> { System.out.println("\t\t-Start: " + ex.getStartDate()); System.out.println("\t\t-Stop: " + ex.getStopDate()); System.out.println("\t\t-Name: " + ex.getName()); System.out.println("\t\t-Status: " + ex.getStatus()); System.out.println(); }); }); } } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means" + " your request made it to Amazon Step Functions, but was" + " rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means " + "the client encountered a serious internal problem while " + "trying to communicate with Step Functions, such as not " + "being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }