Example usage for com.amazonaws.auth InstanceProfileCredentialsProvider InstanceProfileCredentialsProvider

List of usage examples for com.amazonaws.auth InstanceProfileCredentialsProvider InstanceProfileCredentialsProvider

Introduction

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

Prototype

@Deprecated
public InstanceProfileCredentialsProvider() 

Source Link

Usage

From source file:CustomCredentialsProviderChain.java

License:Open Source License

public CustomCredentialsProviderChain() {
    super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(),
            new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider());
}

From source file:SampleKinesisApplication.java

License:Open Source License

private static void configure(String propertiesFile) throws IOException {

    if (propertiesFile != null) {
        loadProperties(propertiesFile);/* ww  w .j  av a  2s. c  om*/
    }

    // ensure the JVM will refresh the cached IP values of AWS resources (e.g. service endpoints).
    java.security.Security.setProperty("networkaddress.cache.ttl", "60");

    String workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" + UUID.randomUUID();
    LOG.info("Using workerId: " + workerId);

    // Get credentials from IMDS. If unsuccessful, get them from the credential profiles file.
    AWSCredentialsProvider credentialsProvider = null;
    try {
        credentialsProvider = new InstanceProfileCredentialsProvider();
        // Verify we can fetch credentials from the provider
        credentialsProvider.getCredentials();
        LOG.info("Obtained credentials from the IMDS.");
    } catch (AmazonClientException e) {
        LOG.info("Unable to obtain credentials from the IMDS, trying classpath properties", e);
        credentialsProvider = new ProfileCredentialsProvider();
        // Verify we can fetch credentials from the provider
        credentialsProvider.getCredentials();
        LOG.info("Obtained credentials from the properties file.");
    }

    LOG.info("Using credentials with access key id: "
            + credentialsProvider.getCredentials().getAWSAccessKeyId());

    kinesisClientLibConfiguration = new KinesisClientLibConfiguration(applicationName, streamName,
            credentialsProvider, workerId).withInitialPositionInStream(initialPositionInStream);
}

From source file:c3.ops.priam.aws.IAMCredential.java

License:Apache License

public IAMCredential() {
    this.iamCredProvider = new InstanceProfileCredentialsProvider();
}

From source file:com.amazon.kinesis.streaming.agent.AgentAWSCredentialsProviderChain.java

License:Open Source License

public AgentAWSCredentialsProviderChain(AgentConfiguration config) {
    super(new AgentAWSCredentialsProvider(config), new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(), new ContainerCredentialsProvider(),
            new ProfileCredentialsProvider(), new InstanceProfileCredentialsProvider());
}

From source file:com.amediamanager.config.S3ConfigurationProvider.java

License:Apache License

@Override
public void loadProperties() {
    this.properties = null;

    // Load properties if there is a bucket and key
    if (bucket != null && key != null) {
        AWSCredentialsProvider creds = new AWSCredentialsProviderChain(new InstanceProfileCredentialsProvider(),
                new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider());
        AmazonS3 s3Client = new AmazonS3Client(creds);
        try {//from   w  ww  .  ja  va2  s  . co  m
            S3Object object = s3Client.getObject(this.bucket, this.key);
            if (object != null) {
                this.properties = new Properties();
                try {
                    this.properties.load(object.getObjectContent());
                } catch (IOException e) {
                    this.properties = null;
                    LOG.warn("Found configuration file in S3 but failed to load properties (s3://{}/{})",
                            new Object[] { this.bucket, this.key, e });
                } finally {
                    try {
                        object.close();
                    } catch (IOException e) {
                        // Don't care
                    }
                }
            }
        } catch (AmazonS3Exception ase) {
            LOG.error("Error loading config from s3://{}/{}", new Object[] { this.bucket, this.key, ase });
        }
    }
}

From source file:com.amediamanager.springconfig.ServerConfig.java

License:Apache License

@Bean
@Scope(WebApplicationContext.SCOPE_APPLICATION)
public AWSCredentialsProvider credentials() {
    return new AWSCredentialsProviderChain(new InstanceProfileCredentialsProvider(),
            new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider());
}

From source file:com.app.dynamoDb.DynamoFacebookUsers.java

License:Open Source License

public DynamoFacebookUsers() {

    //   credentials = new ProfileCredentialsProvider("default").getCredentials();
    dynamoDB = new AmazonDynamoDBClient(new AWSCredentialsProviderChain(
            new InstanceProfileCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider()));
    Region usWest2 = Region.getRegion(Regions.US_WEST_2);
    dynamoDB.setRegion(usWest2);/*from w ww  .  j a v a 2 s . c  om*/
}

From source file:com.app.dynamoDb.DynamoUser.java

License:Open Source License

public DynamoUser() {

    //credentials = new ProfileCredentialsProvider("default").getCredentials();
    dynamoDB = new AmazonDynamoDBClient(new AWSCredentialsProviderChain(
            new InstanceProfileCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider()));
    Region usWest2 = Region.getRegion(Regions.US_WEST_2);
    dynamoDB.setRegion(usWest2);//from w w  w. j a v a 2s  .c om
}

From source file:com.aws.credentials.AWSCredentialsProvider.java

License:Open Source License

public AWSCredentialsProvider() {

    super(new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider());
}

From source file:com.dssmp.agent.AgentAWSCredentialsProviderChain.java

License:Apache License

public AgentAWSCredentialsProviderChain(AgentConfiguration config) {
    super(new AgentAWSCredentialsProvider(config), new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(), new ProfileCredentialsProvider(),
            new InstanceProfileCredentialsProvider());
}