@@ -48,7 +48,6 @@ export interface SDKOptions {
4848export class SDK {
4949 private readonly defaultAwsAccount : DefaultAWSAccount ;
5050 private readonly credentialsCache : CredentialsCache ;
51- private readonly defaultClientArgs : any = { } ;
5251 private readonly profile ?: string ;
5352
5453 constructor ( options : SDKOptions ) {
@@ -58,52 +57,50 @@ export class SDK {
5857
5958 // Find the package.json from the main toolkit
6059 const pkg = ( require . main as any ) . require ( '../package.json' ) ;
61- this . defaultClientArgs . userAgent = `${ pkg . name } /${ pkg . version } ` ;
60+ AWS . config . update ( {
61+ customUserAgent : `${ pkg . name } /${ pkg . version } `
62+ } ) ;
6263
6364 // https://aws.amazon.com/blogs/developer/using-the-aws-sdk-for-javascript-from-behind-a-proxy/
6465 if ( options . proxyAddress === undefined ) {
6566 options . proxyAddress = httpsProxyFromEnvironment ( ) ;
6667 }
6768 if ( options . proxyAddress ) { // Ignore empty string on purpose
6869 debug ( 'Using proxy server: %s' , options . proxyAddress ) ;
69- this . defaultClientArgs . httpOptions = {
70- agent : require ( 'proxy-agent' ) ( options . proxyAddress )
71- } ;
70+ AWS . config . update ( {
71+ httpOptions : { agent : require ( 'proxy-agent' ) ( options . proxyAddress ) }
72+ } ) ;
7273 }
7374
74- this . defaultAwsAccount = new DefaultAWSAccount ( defaultCredentialProvider , this . defaultClientArgs ) ;
75+ this . defaultAwsAccount = new DefaultAWSAccount ( defaultCredentialProvider ) ;
7576 this . credentialsCache = new CredentialsCache ( this . defaultAwsAccount , defaultCredentialProvider ) ;
7677 }
7778
7879 public async cloudFormation ( environment : Environment , mode : Mode ) : Promise < AWS . CloudFormation > {
7980 return new AWS . CloudFormation ( {
8081 region : environment . region ,
81- credentials : await this . credentialsCache . get ( environment . account , mode ) ,
82- ...this . defaultClientArgs
82+ credentials : await this . credentialsCache . get ( environment . account , mode )
8383 } ) ;
8484 }
8585
8686 public async ec2 ( awsAccountId : string | undefined , region : string | undefined , mode : Mode ) : Promise < AWS . EC2 > {
8787 return new AWS . EC2 ( {
8888 region,
89- credentials : await this . credentialsCache . get ( awsAccountId , mode ) ,
90- ...this . defaultClientArgs
89+ credentials : await this . credentialsCache . get ( awsAccountId , mode )
9190 } ) ;
9291 }
9392
9493 public async ssm ( awsAccountId : string | undefined , region : string | undefined , mode : Mode ) : Promise < AWS . SSM > {
9594 return new AWS . SSM ( {
9695 region,
97- credentials : await this . credentialsCache . get ( awsAccountId , mode ) ,
98- ...this . defaultClientArgs
96+ credentials : await this . credentialsCache . get ( awsAccountId , mode )
9997 } ) ;
10098 }
10199
102100 public async s3 ( environment : Environment , mode : Mode ) : Promise < AWS . S3 > {
103101 return new AWS . S3 ( {
104102 region : environment . region ,
105- credentials : await this . credentialsCache . get ( environment . account , mode ) ,
106- ...this . defaultClientArgs
103+ credentials : await this . credentialsCache . get ( environment . account , mode )
107104 } ) ;
108105 }
109106
@@ -195,7 +192,7 @@ class DefaultAWSAccount {
195192 private defaultAccountId ?: string = undefined ;
196193 private readonly accountCache = new AccountAccessKeyCache ( ) ;
197194
198- constructor ( private readonly defaultCredentialsProvider : Promise < AWS . CredentialProviderChain > , private readonly defaultClientArgs : any ) {
195+ constructor ( private readonly defaultCredentialsProvider : Promise < AWS . CredentialProviderChain > ) {
199196 }
200197
201198 /**
@@ -223,7 +220,7 @@ class DefaultAWSAccount {
223220 const accountId = await this . accountCache . fetch ( creds . accessKeyId , async ( ) => {
224221 // if we don't have one, resolve from STS and store in cache.
225222 debug ( 'Looking up default account ID from STS' ) ;
226- const result = await new AWS . STS ( { credentials : creds , ... this . defaultClientArgs } ) . getCallerIdentity ( ) . promise ( ) ;
223+ const result = await new AWS . STS ( { credentials : creds } ) . getCallerIdentity ( ) . promise ( ) ;
227224 const aid = result . Account ;
228225 if ( ! aid ) {
229226 debug ( 'STS didn\'t return an account ID' ) ;
0 commit comments