@@ -88,23 +88,23 @@ export class SdkProvider {
88
88
* class `AwsCliCompatible` for the details.
89
89
*/
90
90
public static async withAwsCliCompatibleDefaults ( options : SdkProviderOptions = { } ) {
91
- const chain = await AwsCliCompatible . credentialChain ( options . profile , options . ec2creds , options . containerCreds ) ;
91
+ const sdkOptions = parseHttpOptions ( options . httpOptions ?? { } ) ;
92
+
93
+ const chain = await AwsCliCompatible . credentialChain ( options . profile , options . ec2creds , options . containerCreds , sdkOptions . httpOptions ) ;
92
94
const region = await AwsCliCompatible . region ( options . profile ) ;
93
95
94
- return new SdkProvider ( chain , region , options . httpOptions ) ;
96
+ return new SdkProvider ( chain , region , sdkOptions ) ;
95
97
}
96
98
97
99
private readonly plugins = new CredentialPlugins ( ) ;
98
- private readonly httpOptions : ConfigurationOptions ;
99
100
100
101
public constructor (
101
102
private readonly defaultChain : AWS . CredentialProviderChain ,
102
103
/**
103
104
* Default region
104
105
*/
105
106
public readonly defaultRegion : string ,
106
- httpOptions : SdkHttpOptions = { } ) {
107
- this . httpOptions = defaultHttpOptions ( httpOptions ) ;
107
+ private readonly sdkOptions : ConfigurationOptions = { } ) {
108
108
}
109
109
110
110
/**
@@ -116,7 +116,7 @@ export class SdkProvider {
116
116
public async forEnvironment ( accountId : string | undefined , region : string | undefined , mode : Mode ) : Promise < ISDK > {
117
117
const env = await this . resolveEnvironment ( accountId , region ) ;
118
118
const creds = await this . obtainCredentials ( env . account , mode ) ;
119
- return new SDK ( creds , env . region , this . httpOptions ) ;
119
+ return new SDK ( creds , env . region , this . sdkOptions ) ;
120
120
}
121
121
122
122
/**
@@ -139,12 +139,12 @@ export class SdkProvider {
139
139
} ,
140
140
stsConfig : {
141
141
region,
142
- ...this . httpOptions ,
142
+ ...this . sdkOptions ,
143
143
} ,
144
144
masterCredentials : await this . defaultCredentials ( ) ,
145
145
} ) ;
146
146
147
- return new SDK ( creds , region , this . httpOptions ) ;
147
+ return new SDK ( creds , region , this . sdkOptions ) ;
148
148
}
149
149
150
150
/**
@@ -199,7 +199,7 @@ export class SdkProvider {
199
199
throw new Error ( 'Unable to resolve AWS credentials (setup with "aws configure")' ) ;
200
200
}
201
201
202
- return new SDK ( creds , this . defaultRegion , this . httpOptions ) . currentAccount ( ) ;
202
+ return new SDK ( creds , this . defaultRegion , this . sdkOptions ) . currentAccount ( ) ;
203
203
} catch ( e ) {
204
204
debug ( 'Unable to determine the default AWS account:' , e ) ;
205
205
return undefined ;
@@ -269,8 +269,11 @@ export interface Account {
269
269
* Get HTTP options for the SDK
270
270
*
271
271
* Read from user input or environment variables.
272
+ *
273
+ * Returns a complete `ConfigurationOptions` object because that's where
274
+ * `customUserAgent` lives, but `httpOptions` is the most important attribute.
272
275
*/
273
- function defaultHttpOptions ( options : SdkHttpOptions ) {
276
+ function parseHttpOptions ( options : SdkHttpOptions ) {
274
277
const config : ConfigurationOptions = { } ;
275
278
config . httpOptions = { } ;
276
279
@@ -298,6 +301,7 @@ function defaultHttpOptions(options: SdkHttpOptions) {
298
301
debug ( 'Using proxy server: %s' , proxyAddress ) ;
299
302
// eslint-disable-next-line @typescript-eslint/no-require-imports
300
303
const ProxyAgent : any = require ( 'proxy-agent' ) ;
304
+ // tslint:disable-next-line:no-console
301
305
config . httpOptions . agent = new ProxyAgent ( proxyAddress ) ;
302
306
}
303
307
if ( caBundlePath ) {
0 commit comments