Amazon Web Services Bootcamp
上QQ阅读APP看书,第一时间看更新

AWS SDK – Java

AWS SDK allows us to use the IAM service via the SDK in multiple languages so that we can customize it as per our choices. To access the IAM service, we need to create the AmazonIdentityManagement object as follows:

AmazonIdentityManagement amazonIdentityManagement =  
AmazonIdentityManagementClientBuilder
.standard() //.withClientConfiguration(getClientConfiguration())
.withCredentials(getCredentials())
.withRegion(Regions.US_EAST_1)
.build(); public ClientConfiguration getClientConfiguration() {
return new ClientConfiguration()
.withProxyUsername("PROXY_USERNAME")
.withProxyPassword("PROXY_PASSWORD")
.withProtocol(Protocol.HTTPS)
.withProxyHost("PROXY_HOSTNAME")
.withProxyPort(80);
} public AWSCredentialsProvider getCredentials() {
// return new AWSStaticCredentialsProvider(new BasicAWSCredentials("ACCESS_KEY", "SECRET_KEY"));
return new ProfileCredentialsProvider("aws-bootcamp");
}

When your code is executed behind the proxy server, you need to set the client configuration properties. We can use any of the Credentials Provider techniques to create the AWSCredentialsProvider object. Here, we have added access key ID and secret key in the C://Users/{USER}/.aws/credentials file with the profile name aws-bootcamp.