List of usage examples for com.amazonaws.auth BasicAWSCredentials BasicAWSCredentials
public BasicAWSCredentials(String accessKey, String secretKey)
From source file:beanstalk.BeanstalkDeployGUI.java
License:Apache License
public boolean deploy(String war, String AWSKeyId, String AWSSecretKey, String applicationname, String applicationversion, String environment, String bucket, String host) {//throws Exception { boolean ret = false; // credentials = new PropertiesCredentials(BeanstalkDeploy.class.getResourceAsStream("AwsCredentials.properties")) BasicAWSCredentials basic_credentials = new BasicAWSCredentials(AWSKeyId, AWSSecretKey); // TransferManager manages a pool of threads, so we create a // single instance and share it throughout our application. tx = new TransferManager(basic_credentials); appname = applicationname;//from w ww .j a va 2 s .co m appversion = applicationversion; accessKeyId = AWSKeyId; secretAccessKey = AWSSecretKey; bucketName = bucket; environment_name = environment; host_name = host; //STEP 1: UPLOAD //STEP 2: CREATE APP VERSION //STEP 3: DEPLOY //TODO //take war file path from args //local_filename_and_path ="../sdsdsds/sts.war"; /// new BeanstalkDeploy(args); return ret; }
From source file:beanstalk.BeanstalkDeployNoGUI.java
License:Apache License
public boolean deploy(String war, String AWSKeyId, String AWSSecretKey, String applicationname, String applicationversion, String environment, String bucket, String host) throws BeanstalkAdapterException { boolean ret = false; // credentials = new PropertiesCredentials(BeanstalkDeployNoGUI.class.getResourceAsStream("AwsCredentials.properties")) BasicAWSCredentials basic_credentials = new BasicAWSCredentials(AWSKeyId, AWSSecretKey); // TransferManager manages a pool of threads, so we create a // single instance and share it throughout our application. // tx = new TransferManager(basic_credentials); appname = applicationname;//from w ww. j a v a 2 s .c o m appversion = applicationversion; accessKeyId = AWSKeyId; secretAccessKey = AWSSecretKey; bucketName = bucket; environment_name = environment; host_name = host; war_name_on_s3 = war; //STEP 1: UPLOAD //STEP 2: CREATE APP VERSION //STEP 3: DEPLOY // if(war.equalsIgnoreCase("")){ // NoGUI ngui= new NoGUI(); // ngui.performDeploydeploy("/home/jled/NetBeansProjects/WebApplication1/dist/WebApplication1.war",accessKeyId , secretAccessKey, appname, appversion, // environment_name,bucketName, host_name); // } //TODO //take war file path from args //local_filename_and_path ="../sdsdsds/sts.war"; /// new BeanstalkDeployNoGUI(args); actionPerformed(war_name_on_s3, accessKeyId, secretAccessKey, appname, appversion, environment_name, bucketName, host_name); return ret; }
From source file:beanstalk.BeanstalkDeployNoGUI.java
License:Apache License
public void upload_file_to_s3(String bucketName, String keyName, String uploadFileName, String AWSKeyId, String AWSSecretKey) throws BeanstalkAdapterException { BasicAWSCredentials basic_credentials = new BasicAWSCredentials(AWSKeyId, AWSSecretKey); AmazonS3 s3client = new AmazonS3Client(basic_credentials); try {//from w w w . j a va 2s . c o m System.out.println("Uploading a new object to S3 from a file\n"); File file = new File(uploadFileName); s3client.putObject(new PutObjectRequest(bucketName, keyName, file)); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which " + "means your request made it " + "to Amazon S3, 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()); throw new BeanstalkAdapterException(ase.getMessage()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which " + "means the client encountered " + "an internal error while trying to " + "communicate with S3, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); throw new BeanstalkAdapterException(ace.getMessage()); } }
From source file:beanstalk.BeanstalkFirstDeploymentNoGUI.java
License:Apache License
public boolean deploy(String war, String AWSKeyId, String AWSSecretKey, String applicationname, String applicationversion, String environment, String bucket, String host) throws BeanstalkAdapterException { boolean ret = false; // credentials = new PropertiesCredentials(BeanstalkDeploy.class.getResourceAsStream("AwsCredentials.properties")) BasicAWSCredentials basic_credentials = new BasicAWSCredentials(AWSKeyId, AWSSecretKey); // TransferManager manages a pool of threads, so we create a // single instance and share it throughout our application. tx = new TransferManager(basic_credentials); appname = applicationname;/*from www .j a va 2 s.co m*/ appversion = applicationversion; accessKeyId = AWSKeyId; secretAccessKey = AWSSecretKey; bucketName = bucket; environment_name = environment; host_name = host; war_name_on_s3 = war; //STEP 1: UPLOAD //STEP 2: CREATE APP VERSION //STEP 3: DEPLOY //TODO //take war file path from args //local_filename_and_path ="../sdsdsds/sts.war"; actionPerformed(war_name_on_s3, accessKeyId, secretAccessKey, appname, appversion, environment_name, bucketName, host_name); return ret; }
From source file:beanstalk.BeanstalkFirstDeploymentNoGUI.java
License:Apache License
public void upload_file_to_s3(String bucketName, String keyName, String uploadFileName, String AWSKeyId, String AWSSecretKey) throws BeanstalkAdapterException { BasicAWSCredentials basic_credentials = new BasicAWSCredentials(AWSKeyId, AWSSecretKey); AmazonS3 s3client = new AmazonS3Client(basic_credentials); try {//from w ww . jav a 2 s . c om System.out.println("Uploading a new object to S3 from a file\n"); File file = new File(uploadFileName); s3client.putObject(new PutObjectRequest(bucketName, keyName, file)); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which " + "means your request made it " + "to Amazon S3, 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()); throw new BeanstalkAdapterException(ase.getMessage()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which " + "means the client encountered " + "an internal error while trying to " + "communicate with S3, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); throw new BeanstalkAdapterException(ace.getMessage()); } }
From source file:biz.neustar.webmetrics.plugins.neustar_s3_maven_plugin.S3UploadMojo.java
License:Apache License
/** */ private static AmazonS3 getS3Client(String accessKey, String secretKey) { AWSCredentialsProvider provider = null; if (accessKey != null && secretKey != null) { AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); provider = new StaticCredentialsProvider(credentials); } else {/* ww w . ja va2 s . co m*/ provider = new DefaultAWSCredentialsProviderChain(); } return new AmazonS3Client(provider); }
From source file:br.com.faccilitacorretor.middleware.dynamo.AmazonDynamoDBSample.java
License:Open Source License
/** * The only information needed to create a client are security credentials * consisting of the AWS Access Key ID and Secret Access Key. All other * configuration, such as the service endpoints, are performed * automatically. Client parameters, such as proxies, can be specified in an * optional ClientConfiguration object when constructing a client. * * @see com.amazonaws.auth.BasicAWSCredentials * @see com.amazonaws.auth.ProfilesConfigFile * @see com.amazonaws.ClientConfiguration *//* w ww.ja v a 2s. co m*/ private static void init() throws Exception { /* * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (/home/turbiani/.aws/credentials). */ AWSCredentials credentials = null; try { credentials = new BasicAWSCredentials(PropertiesConfig.getInstance().get("ACCESS_KEY"), PropertiesConfig.getInstance().get("SECRET_ACCESS_KEY")); } 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 (/home/turbiani/.aws/credentials), and is in valid format.", e); } dynamoDB = new AmazonDynamoDBClient(credentials); Region usEast1 = Region.getRegion(Regions.US_EAST_1); dynamoDB.setRegion(usEast1); }
From source file:br.com.ingenieux.jenkins.plugins.awsebdeployment.Deployer.java
License:Apache License
private void initAWS() { log("Creating S3 and AWSEB Client (AWS Access Key Id: %s, region: %s)", context.getAwsAccessKeyId(), context.getAwsRegion());/* w w w . j a v a 2s. c o m*/ AWSCredentialsProvider credentials = new AWSCredentialsProviderChain(new StaticCredentialsProvider( new BasicAWSCredentials(context.getAwsAccessKeyId(), context.getAwsSecretSharedKey()))); Region region = Region.getRegion(Regions.fromName(context.getAwsRegion())); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setUserAgent("ingenieux CloudButler/" + getVersion()); s3 = region.createClient(AmazonS3Client.class, credentials, clientConfig); awseb = region.createClient(AWSElasticBeanstalkClient.class, credentials, clientConfig); }
From source file:br.com.insula.log4j.sns.SNSAppender.java
License:Open Source License
private void createAmazonSNSAsyncIfNeeded() { if (this.amazonSNSAsync == null) { this.amazonSNSAsync = new AmazonSNSAsyncClient(new BasicAWSCredentials(accessKey, secretKey)); }//from ww w. j a v a 2 s . com }
From source file:br.com.objectos.aws.rds.maven.plugin.CreateSnapshotMojo.java
License:Apache License
private void execute0() throws MojoExecutionException { AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); AmazonRDSClient client = new AmazonRDSClient(credentials); CreateDBSnapshotRequest createDBSnapshotRequest = new CreateDBSnapshotRequest() .withDBInstanceIdentifier(dBInstanceIdentifier).withDBSnapshotIdentifier(dBSnapshotIdentifier); info("Starting RDS Snapshot '%s' at '%s'", dBSnapshotIdentifier, dBInstanceIdentifier); long startTime = System.currentTimeMillis(); DBSnapshot snapshot = client.createDBSnapshot(createDBSnapshotRequest); info("Backing up... please wait."); while (!isDone(snapshot)) { try {//from w w w . ja v a 2 s . c om Thread.sleep(5000); snapshot = describeSnapshot(client); if (snapshot == null) { break; } } catch (InterruptedException e) { throw new MojoExecutionException("Interrupted while waiting", e); } } long endTime = System.currentTimeMillis(); info("Snapshot took %d ms", endTime - startTime); }