Search in sources :

Example 1 with AmazonCloudWatchClient

use of com.amazonaws.services.cloudwatch.AmazonCloudWatchClient in project camel by apache.

the class CwEndpoint method createCloudWatchClient.

AmazonCloudWatch createCloudWatchClient() {
    AmazonCloudWatch client = null;
    ClientConfiguration clientConfiguration = null;
    boolean isClientConfigFound = false;
    if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
        clientConfiguration = new ClientConfiguration();
        clientConfiguration.setProxyHost(configuration.getProxyHost());
        clientConfiguration.setProxyPort(configuration.getProxyPort());
        isClientConfigFound = true;
    }
    if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
        if (isClientConfigFound) {
            client = new AmazonCloudWatchClient(credentials, clientConfiguration);
        } else {
            client = new AmazonCloudWatchClient(credentials);
        }
    } else {
        if (isClientConfigFound) {
            client = new AmazonCloudWatchClient();
        } else {
            client = new AmazonCloudWatchClient(clientConfiguration);
        }
    }
    return client;
}
Also used : AmazonCloudWatchClient(com.amazonaws.services.cloudwatch.AmazonCloudWatchClient) AmazonCloudWatch(com.amazonaws.services.cloudwatch.AmazonCloudWatch) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 2 with AmazonCloudWatchClient

use of com.amazonaws.services.cloudwatch.AmazonCloudWatchClient in project jmxtrans by jmxtrans.

the class CloudWatchWriter method createCloudWatchClient.

/**
	 * Configuring the CloudWatch client.
	 *
	 * Credentials are loaded from the Amazon EC2 Instance Metadata Service
	 */
private AmazonCloudWatchClient createCloudWatchClient() {
    AmazonCloudWatchClient cloudWatchClient = new AmazonCloudWatchClient(new InstanceProfileCredentialsProvider());
    cloudWatchClient.setRegion(checkNotNull(Regions.getCurrentRegion(), "Problems getting AWS metadata"));
    return cloudWatchClient;
}
Also used : InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) AmazonCloudWatchClient(com.amazonaws.services.cloudwatch.AmazonCloudWatchClient)

Example 3 with AmazonCloudWatchClient

use of com.amazonaws.services.cloudwatch.AmazonCloudWatchClient in project chassis by Kixeye.

the class DefaultCloudWatchFactory method getCloudWatchClient.

@Override
public AmazonCloudWatchClient getCloudWatchClient() {
    AmazonCloudWatchClient client;
    if (StringUtils.isBlank(accessKeyId) || StringUtils.isBlank(secretKey)) {
        LOGGER.debug("Constructing AmazonCloudWatchClient using DefaultAWSCredentialsProviderChain for region {}.", region);
        client = new AmazonCloudWatchClient(new DefaultAWSCredentialsProviderChain());
    } else {
        LOGGER.debug("Constructing AmazonCloudWatchClient from given credentials for region {}.", region);
        client = new AmazonCloudWatchClient(new BasicAWSCredentials(accessKeyId, secretKey));
    }
    client.setRegion(region);
    return client;
}
Also used : DefaultAWSCredentialsProviderChain(com.amazonaws.auth.DefaultAWSCredentialsProviderChain) AmazonCloudWatchClient(com.amazonaws.services.cloudwatch.AmazonCloudWatchClient) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Aggregations

AmazonCloudWatchClient (com.amazonaws.services.cloudwatch.AmazonCloudWatchClient)3 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)2 ClientConfiguration (com.amazonaws.ClientConfiguration)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 DefaultAWSCredentialsProviderChain (com.amazonaws.auth.DefaultAWSCredentialsProviderChain)1 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)1 AmazonCloudWatch (com.amazonaws.services.cloudwatch.AmazonCloudWatch)1