/** * Fetch AWS session credentials from EC2 instance data available * with the given role name. * * Instance data is expected at the default EC2 endpoint: * http://169.254.169.254/latest/meta-data/iam/security-credentials/<roleName> * * @param roleName * Name of the IAM role provided in the EC2 to supply S3 access credentials * @param automaticRefreshEnabled * if true, the returned credentials object will automatically refresh * the session token and credentials if they are nearly expired * @return * populated credentials object */ public static AWSEC2IAMSessionCredentials loadFromEC2InstanceData( String roleName, boolean automaticRefreshEnabled) { return AWSEC2IAMSessionCredentials.loadFromEC2InstanceData( baseCredentialsUrl, roleName, automaticRefreshEnabled); }
/** * Fetch AWS session credentials from EC2 instance data available * with the given role name. * * Instance data is expected at the default EC2 endpoint: * http://169.254.169.254/latest/meta-data/iam/security-credentials/<roleName> * * @param roleName * Name of the IAM role provided in the EC2 to supply S3 access credentials * @param automaticRefreshEnabled * if true, the returned credentials object will automatically refresh * the session token and credentials if they are nearly expired * @return * populated credentials object */ public static AWSEC2IAMSessionCredentials loadFromEC2InstanceData( String roleName, boolean automaticRefreshEnabled) { return AWSEC2IAMSessionCredentials.loadFromEC2InstanceData( baseCredentialsUrl, roleName, automaticRefreshEnabled); }
throw new RuntimeException("Empty IAM role name in EC2 meta data!"); return AWSEC2IAMSessionCredentials.loadFromEC2InstanceData( baseCredentialsUrl, roleName, automaticRefreshEnabled);
throw new RuntimeException("Empty IAM role name in EC2 meta data!"); return AWSEC2IAMSessionCredentials.loadFromEC2InstanceData( baseCredentialsUrl, roleName, automaticRefreshEnabled);
/** * Fetch IAM role credentials from EC2 instance data and re-populate * this object. */ public void refreshFromEC2InstanceData() { AWSEC2IAMSessionCredentials loadedCredentials = AWSEC2IAMSessionCredentials.loadFromEC2InstanceData( this.roleName, this.automaticRefreshEnabled); this.accessKey = loadedCredentials.getAccessKey(); this.secretKey = loadedCredentials.getSecretKey(); this.sessionToken = loadedCredentials.getSessionToken(); this.expiration = loadedCredentials.getExpiration(); }
/** * Fetch IAM role credentials from EC2 instance data and re-populate * this object. */ public void refreshFromEC2InstanceData() { AWSEC2IAMSessionCredentials loadedCredentials = AWSEC2IAMSessionCredentials.loadFromEC2InstanceData( this.roleName, this.automaticRefreshEnabled); this.accessKey = loadedCredentials.getAccessKey(); this.secretKey = loadedCredentials.getSecretKey(); this.sessionToken = loadedCredentials.getSessionToken(); this.expiration = loadedCredentials.getExpiration(); }