Example usage for com.amazonaws.auth AWSCredentials getAWSAccessKeyId

List of usage examples for com.amazonaws.auth AWSCredentials getAWSAccessKeyId

Introduction

In this page you can find the example usage for com.amazonaws.auth AWSCredentials getAWSAccessKeyId.

Prototype

public String getAWSAccessKeyId();

Source Link

Document

Returns the AWS access key ID for this credentials object.

Usage

From source file:fr.xebia.workshop.bigdata.DocumentationGenerator.java

License:Apache License

public static void main(String[] args) {
    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();

    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure()
            .withTeamIdentifiers("1", "2"/*, "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"*/)
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("xte-flume");

    DocumentationGenerator documentationGenerator = new DocumentationGenerator();
    try {//from  w w  w .ja v  a 2s  .c om
        documentationGenerator.generateDocs(workshopInfrastructure, "target/wiki/");
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:fr.xebia.workshop.bigdata.WorkshopInfrastructureCreator.java

License:Apache License

public static void main(String args[]) {

    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();
    AmazonEC2 ec2 = new AmazonEC2Client(awsCredentials);
    ec2.setEndpoint("ec2.eu-west-1.amazonaws.com");

    AmazonRoute53 route53 = new AmazonRoute53Client(awsCredentials);

    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure().withTeamIdentifiers("1" /* ,"2"
                                                                                                         * , "3", "4", "5", "6", "7", "8",
                                                                                                         * "9", "10", "11"
                                                                                                         */)
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("xte-flume");

    // checks for Key in classpath: prevents launching instances if not
    // present//from  ww w  .  j a v a2  s. co m
    checkKeyFile(workshopInfrastructure);

    AmazonAwsUtils.terminateInstancesByWorkshop("flume-hadoop", ec2);

    ExecutorService executor = Executors.newFixedThreadPool(3);

    //executor.execute(new CreateTomcatServers(ec2, route53,
    //        workshopInfrastructure));

    executor.execute(new CreateHadoopMasterNode(ec2, route53, workshopInfrastructure));

    executor.execute(new CreateHadoopSlaveNode(ec2, route53, workshopInfrastructure));

    executor.shutdown();

    try {
        executor.awaitTermination(10, TimeUnit.MINUTES);
        executor.shutdownNow();
    } catch (Exception e) {
        logger.error(e.getMessage());
    }

    logger.info("Workshop infrastructure created");

}

From source file:fr.xebia.workshop.caching.CreateCachingProxyServers.java

License:Apache License

public static void main(String[] args) {
    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();
    AmazonEC2 ec2 = new AmazonEC2Client(awsCredentials);
    ec2.setEndpoint("ec2.eu-west-1.amazonaws.com");

    AmazonRoute53 route53 = new AmazonRoute53Client(awsCredentials);

    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure()
            .withTeamIdentifiers("1", "2", "3"/*, "4", "5", "6", "7", "8", "9", "10", "11"*/)
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("web-caching-workshop")
            .withBeanstalkNotificationEmail("cleclerc@xebia.fr");

    CreateCachingProxyServers job = new CreateCachingProxyServers(ec2, route53, workshopInfrastructure);
    job.run();//w ww . j av a2s .  c om

}

From source file:fr.xebia.workshop.caching.CreateTomcat.java

License:Apache License

public static void main(String[] args) throws Exception {

    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();
    AWSElasticBeanstalk beanstalk = new AWSElasticBeanstalkClient(awsCredentials);
    beanstalk.setEndpoint("elasticbeanstalk.eu-west-1.amazonaws.com");

    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure()
            .withTeamIdentifiers("1" /*, "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"*/)
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("web-caching-workshop")
            .withBeanstalkNotificationEmail("cleclerc@xebia.fr");
    CreateTomcat createTomcat = new CreateTomcat(beanstalk, workshopInfrastructure);
    createTomcat.createServers();/*from w  w  w .j av  a  2s . co  m*/
}

From source file:fr.xebia.workshop.caching.DocumentationGenerator.java

License:Apache License

public static void main(String[] args) {
    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();

    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure()
            .withTeamIdentifiers("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("web-caching-workshop")
            .withBeanstalkNotificationEmail("cleclerc@xebia.fr");

    DocumentationGenerator documentationGenerator = new DocumentationGenerator();
    try {/*from w  w  w. j  av  a  2  s  .co  m*/
        documentationGenerator.generateDocs(workshopInfrastructure, "target/wiki/");
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:fr.xebia.workshop.caching.WorkshopInfrastructureCreator.java

License:Apache License

public static void main(String[] args) {

    // AMAZON SERVICES
    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();
    AmazonEC2 ec2 = new AmazonEC2Client(awsCredentials);
    ec2.setEndpoint("ec2.eu-west-1.amazonaws.com");

    AWSElasticBeanstalk beanstalk = new AWSElasticBeanstalkClient(awsCredentials);
    beanstalk.setEndpoint("elasticbeanstalk.eu-west-1.amazonaws.com");

    AmazonRoute53 route53 = new AmazonRoute53Client(awsCredentials);

    ExecutorService executor = Executors.newFixedThreadPool(3);

    // WORKSHOP CONFIGURATION
    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure()
            .withTeamIdentifiers("1", "2" /*, "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" */)
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("web-caching-workshop")
            .withBeanstalkNotificationEmail("cleclerc@xebia.fr");

    // CREATE WORKSHOP INFRASTRUCTURE
    CreateCachingProxyServers createCachingProxyServers = new CreateCachingProxyServers(ec2, route53,
            workshopInfrastructure);/*from   ww  w  . j  a  v a2 s .co  m*/
    executor.execute(createCachingProxyServers);

    CreateTomcat createTomcat = new CreateTomcat(beanstalk, workshopInfrastructure);
    executor.execute(createTomcat);

    executor.shutdown();

    try {
        executor.awaitTermination(10, TimeUnit.MINUTES);
    } catch (Exception e) {
        e.printStackTrace();
    }

    logger.info("Workshop infrastructure created");
}

From source file:fr.xebia.workshop.nginx.CreateNginxProxyServers.java

License:Apache License

public static void main(String[] args) {
    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();
    AmazonEC2 ec2 = new AmazonEC2Client(awsCredentials);
    ec2.setEndpoint("ec2.eu-west-1.amazonaws.com");

    AmazonRoute53 route53 = new AmazonRoute53Client(awsCredentials);

    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure()
            .withTeamIdentifiers("1"/*, "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"*/)
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("nginx-workshop")
            .withBeanstalkNotificationEmail("slemesle@xebia.fr");

    CreateNginxProxyServers job = new CreateNginxProxyServers(ec2, route53, workshopInfrastructure);
    job.run();// w  w w  .  j  a va 2  s  . c  om
    /*
    List<Reservation> reservations = ec2.describeInstances(new DescribeInstancesRequest().withInstanceIds("i-7741eb3f")).getReservations();
    Instance instance = Iterables.getOnlyElement(Iterables.getOnlyElement(reservations).getInstances());
            
    Map<String, Instance> instancesByTeamId = Collections.singletonMap("clc", instance);
            
    job.bindInstancesToDnsCnames(instancesByTeamId, route53);
    */

}

From source file:fr.xebia.workshop.nginx.CreateTomcat.java

License:Apache License

public static void main(String[] args) throws Exception {

    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();
    AWSElasticBeanstalk beanstalk = new AWSElasticBeanstalkClient(awsCredentials);
    beanstalk.setEndpoint("elasticbeanstalk.eu-west-1.amazonaws.com");

    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure()
            .withTeamIdentifiers("1"/*, "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"*/)
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("nginx-workshop")
            .withBeanstalkNotificationEmail("slemesle@xebia.fr");
    CreateTomcat createTomcat = new CreateTomcat(beanstalk, workshopInfrastructure);
    createTomcat.createServers();/*from   www  . ja v a 2s .  c om*/
}

From source file:fr.xebia.workshop.nginx.NginxLabCreator.java

License:Apache License

public static void main(String[] args) {

    AWSCredentials awsCredentials = AmazonAwsUtils.loadAwsCredentials();
    AmazonEC2 ec2 = new AmazonEC2Client(awsCredentials);
    ec2.setEndpoint("ec2.eu-west-1.amazonaws.com");

    AmazonRoute53 route53 = new AmazonRoute53Client(awsCredentials);

    WorkshopInfrastructure workshopInfrastructure = new WorkshopInfrastructure()
            .withTeamIdentifiers("1"/*, "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"*/)
            .withAwsAccessKeyId(awsCredentials.getAWSAccessKeyId())
            .withAwsSecretKey(awsCredentials.getAWSSecretKey()).withKeyPairName("nginx-workshop")
            .withBeanstalkNotificationEmail("slemesle@xebia.fr");

    CreateNginxProxyServers job = new CreateNginxProxyServers(ec2, route53, workshopInfrastructure);
    job.run();/* ww w .j  a v a 2s .  co  m*/

    log.info("All Nginx instances created DNS is http://www-nginx-${team}.aws.xebiatechevent.info/");

    CreateTomcatServers tomcatServers = new CreateTomcatServers(ec2, route53, workshopInfrastructure);
    tomcatServers.run();

    log.info(
            "All Tomcat instances created Route53 is http://xfr-cocktail-nginx-${team}.aws.xebiatechevent.info:[8080/8180]/");
}

From source file:io.hekate.cluster.seed.jclouds.aws.AwsCredentialsSupplier.java

License:Apache License

@Override
public Credentials get() {
    String identity = getIdentity() != null ? getIdentity().trim() : null;
    String credential = getCredential() != null ? getCredential().trim() : null;

    if (identity == null || identity.isEmpty() || credential == null || credential.isEmpty()) {
        DefaultAWSCredentialsProviderChain chain = new DefaultAWSCredentialsProviderChain();

        AWSCredentials cred = chain.getCredentials();

        if (cred instanceof BasicSessionCredentials) {
            BasicSessionCredentials sesCred = (BasicSessionCredentials) cred;

            return new SessionCredentials.Builder().identity(sesCred.getAWSAccessKeyId())
                    .credential(sesCred.getAWSSecretKey()).sessionToken(sesCred.getSessionToken()).build();
        } else {/*w w  w.  j  av  a2s .  co m*/
            return new Credentials.Builder<>().identity(cred.getAWSAccessKeyId())
                    .credential(cred.getAWSSecretKey()).build();
        }
    }

    return super.get();
}