Example usage for com.amazonaws.services.ecs AmazonECSClient AmazonECSClient

List of usage examples for com.amazonaws.services.ecs AmazonECSClient AmazonECSClient

Introduction

In this page you can find the example usage for com.amazonaws.services.ecs AmazonECSClient AmazonECSClient.

Prototype

AmazonECSClient(AwsSyncClientParams clientParams) 

Source Link

Document

Constructs a new client to invoke service methods on Amazon ECS using the specified parameters.

Usage

From source file:com.cloudbees.jenkins.plugins.amazonecs.ECSService.java

License:Open Source License

AmazonECSClient getAmazonECSClient() {
    final AmazonECSClient client;

    ProxyConfiguration proxy = Jenkins.getInstance().proxy;
    ClientConfiguration clientConfiguration = new ClientConfiguration();
    if (proxy != null) {
        clientConfiguration.setProxyHost(proxy.name);
        clientConfiguration.setProxyPort(proxy.port);
        clientConfiguration.setProxyUsername(proxy.getUserName());
        clientConfiguration.setProxyPassword(proxy.getPassword());
    }//from w w w .j a  va  2 s .c o  m

    AmazonWebServicesCredentials credentials = getCredentials(credentialsId);
    if (credentials == null) {
        // no credentials provided, rely on com.amazonaws.auth.DefaultAWSCredentialsProviderChain
        // to use IAM Role define at the EC2 instance level ...
        client = new AmazonECSClient(clientConfiguration);
    } else {
        if (LOGGER.isLoggable(Level.FINE)) {
            String awsAccessKeyId = credentials.getCredentials().getAWSAccessKeyId();
            String obfuscatedAccessKeyId = StringUtils.left(awsAccessKeyId, 4)
                    + StringUtils.repeat("*", awsAccessKeyId.length() - (2 * 4))
                    + StringUtils.right(awsAccessKeyId, 4);
            LOGGER.log(Level.FINE, "Connect to Amazon ECS with IAM Access Key {1}",
                    new Object[] { obfuscatedAccessKeyId });
        }
        client = new AmazonECSClient(credentials, clientConfiguration);
    }
    client.setRegion(getRegion(regionName));
    LOGGER.log(Level.FINE, "Selected Region: {0}", regionName);
    return client;
}