@@ -13,26 +13,16 @@ function CloudwatchBackend(startupTime, config, emitter) {
1313 }
1414
1515 // if iamRole is set attempt to fetch credentials from the Metadata Service
16- if ( this . config . iamRole ) {
17- if ( this . config . iamRole == 'any' ) {
18- // If the iamRole is set to any, then attempt to fetch any available credentials
19- ms = new AWS . EC2MetadataCredentials ( ) ;
20- ms . refresh ( function ( err ) {
21- if ( err ) { console . log ( 'Failed to fetch IAM role credentials: ' + err ) ; }
22- self . config . credentials = ms ;
23- setEmitter ( ) ;
24- } ) ;
25- } else {
26- // however if it's set to specify a role, query it specifically.
27- ms = new AWS . MetadataService ( ) ;
28- ms . request ( '/latest/meta-data/iam/security-credentials/' + this . config . iamRole , function ( err , rdata ) {
29- var data = JSON . parse ( rdata ) ;
30-
31- if ( err ) { console . log ( 'Failed to fetch IAM role credentials: ' + err ) ; }
32- self . config . credentials = new AWS . Credentials ( data . AccessKeyId , data . SecretAccessKey , data . Token ) ;
33- setEmitter ( ) ;
34- } ) ;
35- }
16+ if ( this . config . iamRole && this . config . iamRole !== 'any' ) {
17+ // if it's set to specify a role, query it specifically.
18+ ms = new AWS . MetadataService ( ) ;
19+ ms . request ( '/latest/meta-data/iam/security-credentials/' + this . config . iamRole , function ( err , rdata ) {
20+ var data = JSON . parse ( rdata ) ;
21+
22+ if ( err ) { console . log ( 'Failed to fetch IAM role credentials: ' + err ) ; }
23+ self . config . credentials = new AWS . Credentials ( data . AccessKeyId , data . SecretAccessKey , data . Token ) ;
24+ setEmitter ( ) ;
25+ } ) ;
3626 } else {
3727 setEmitter ( ) ;
3828 }
0 commit comments