Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): proxy is not configured correctly #32213

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions packages/aws-cdk/lib/api/aws-auth/awscli-compatible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as promptly from 'promptly';
import type { SdkHttpOptions } from './sdk-provider';
import { readIfPossible } from './util';
import { debug } from '../../logging';
import { ProxyAgent } from 'proxy-agent';

const DEFAULT_CONNECTION_TIMEOUT = 10000;
const DEFAULT_TIMEOUT = 300000;
Expand Down Expand Up @@ -89,18 +90,23 @@ export class AwsCliCompatible {
}

public static requestHandlerBuilder(options: SdkHttpOptions = {}): NodeHttpHandlerOptions {
const config: NodeHttpHandlerOptions = {
// Force it to use the proxy provided through the command line.
// Otherwise, let the ProxyAgent auto-detect the proxy using environment variables.
const getProxyForUrl = options.proxyAddress != null
? () => Promise.resolve(options.proxyAddress!)
: undefined;

const agent = new ProxyAgent({
ca: tryGetCACert(options.caBundlePath),
getProxyForUrl: getProxyForUrl,
});

return {
connectionTimeout: DEFAULT_CONNECTION_TIMEOUT,
requestTimeout: DEFAULT_TIMEOUT,
httpsAgent: {
ca: tryGetCACert(options.caBundlePath),
localAddress: options.proxyAddress,
},
httpAgent: {
localAddress: options.proxyAddress,
},
httpsAgent: agent,
httpAgent: agent,
};
return config;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/aws-auth/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export class SDK {
region,
credentials: _credentials,
requestHandler,
retryStrategy: new ConfiguredRetryStrategy(7, (attempt) => attempt ** 300),
retryStrategy: new ConfiguredRetryStrategy(7, (attempt) => 300 * (2 ** attempt)),
customUserAgent: defaultCliUserAgent(),
};
this.currentRegion = region;
Expand Down
Loading