amazon web services - Connection Time out making AWS CLI call using : STSAssumeRoleSessionCredentialsProvider -


i running code unix box , , have attached readonly role ec2 instance has cross account access setup. when hop on instance , , run command manually , works :

aws sts assume-role --role-arn arn:aws:iam::093937234853:role/capone-crossaccount-customrole-readonly --role-session-name 123 

i have setup http_proxy , https_proxy , no_proxy=169.254.169.254 manually . when run java program within same session on unix , following exception :

com.amazonaws.amazonclientexception: unable execute http request: connect timed out 

here how assuming role in java:

stsassumerolesessioncredentialsprovider stscred = new stsassumerolesessioncredentialsprovider("arn:aws:iam::093937234853:role/capone-crossaccount-customrole-readonly","123"); 

and getting exception when :

public describeinstancesresult getdescribeinstancesresult() {         if(describeinstancesresult == null){                 try{                         this.setdescribeinstancesresult(this.getresourceclient().describeinstances());                 }catch(amazonclientexception ac){                         system.out.println("error: amazonclientexception connection aws public " + getresourcetype().name() + " services.\n\n" + ac);                 }         }         return describeinstancesresult; } 

do need pass proxy information though have set them manually on same linux session. have tried running following command :

java -dhttp.proxyhost=proxy.kdc.capitalone.com -dhttp.proxyport=8099 -dhttp.nonproxyhosts=169.254.169.254 -jar resourcemetadatareport-00.00.01.00-snapshot.jar  

and setting proxy in java code safe :

    system.setproperty("http.proxyhost", "proxy.kdc.company.com");     system.setproperty("http.proxyport", "8099");     system.setproperty("https.proxyhost", "proxy.kdc.company.com");     system.setproperty("https.proxyport", "8099");               system.setproperty("http.nonproxyhosts", "169.254.169.254"); 

fyi : dont want use methods :

public stsassumerolesessioncredentialsprovider(awscredentialsprovider longlivedcredentialsprovider,                                       java.lang.string rolearn,java.lang.string rolesessionname,clientconfiguration clientconfiguration) 

as should not passing credentials.

to pass proxy information aws client, need declare clientconfiguration like

clientconfiguration clientconf = new clientconfiguration () cc.setproxyhost("proxy.kdc.company.com"); ... 

to use clientconfiguration stsassumerolesessioncredentialsprovider without passing credentials :

stsassumerolesessioncredentialsprovider stscred = new stsassumerolesessioncredentialsprovider(     new stsassumerolesessioncredentialsprovider.builder("arn:aws:iam::093937234853:role/capone-crossaccount-customrole-readonly","123"),      clientconf); 

Comments