If you are behind proxy then these sample projects will not read proxy from eclipse proxy settings.
to fix this issue you have to add some extra lines of code into your sample projects.
Create a object of ClientConfiguration class and set proxyhost and proxyport properties and then pass this object while creating client (ec2,S3 or sdb etc)
so your init method should look something like this after modification
private static void init() throws Exception {
/*
* This credentials provider implementation loads your AWS credentials
* from a properties file at the root of your classpath.
*
*/
ClientConfiguration clientCfg = new ClientConfiguration();
clientCfg.setProtocol(Protocol.HTTP);
//setup proxy connection:
clientCfg.setProxyHost("HTTP_PROXY_IP");
clientCfg.setProxyPort(8080);
AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider();
ec2 = new AmazonEC2Client(credentialsProvider,clientCfg);
s3 = new AmazonS3Client(credentialsProvider,clientCfg);
sdb = new AmazonSimpleDBClient(credentialsProvider,clientCfg);
}
to fix this issue you have to add some extra lines of code into your sample projects.
Create a object of ClientConfiguration class and set proxyhost and proxyport properties and then pass this object while creating client (ec2,S3 or sdb etc)
so your init method should look something like this after modification
private static void init() throws Exception {
/*
* This credentials provider implementation loads your AWS credentials
* from a properties file at the root of your classpath.
*
*/
ClientConfiguration clientCfg = new ClientConfiguration();
clientCfg.setProtocol(Protocol.HTTP);
//setup proxy connection:
clientCfg.setProxyHost("HTTP_PROXY_IP");
clientCfg.setProxyPort(8080);
AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider();
ec2 = new AmazonEC2Client(credentialsProvider,clientCfg);
s3 = new AmazonS3Client(credentialsProvider,clientCfg);
sdb = new AmazonSimpleDBClient(credentialsProvider,clientCfg);
}
hi how can i contact you?
ReplyDeleteI get below error after making changes.
ReplyDeleteCaught Exception: Status Code: 403, AWS Service: AmazonEC2, AWS Request ID: b77729e2-d86d-4e11-a7e8-3295674d8ea7, AWS Error Code: UnauthorizedOperation, AWS Error Message: You are not authorized to perform this operation.
Reponse Status Code: 403
Error Code: UnauthorizedOperation
Request ID: b77729e2-d86d-4e11-a7e8-3295674d8ea7
How to find proxy User name in Office environment