diff --git a/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts b/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts index d8fb031bf638f..ab583611bbc52 100644 --- a/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts +++ b/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts @@ -12,6 +12,12 @@ import { Mode } from '../aws-auth/credentials'; import { AwsCliCompatible } from './awscli-compatible'; import { ISDK, SDK } from './sdk'; + +// Some configuration that can only be achieved by setting +// environment variables. +process.env.AWS_STS_REGIONAL_ENDPOINTS = 'regional'; +process.env.AWS_NODEJS_CONNECTION_REUSE_ENABLED = '1'; + /** * Options for the default SDK provider */ @@ -82,7 +88,7 @@ const CACHED_DEFAULT_CREDENTIALS = Symbol('cached_default_credentials'); */ export class SdkProvider { /** - * Create a new SdkProvider which gets its defaults in a way that haves like the AWS CLI does + * Create a new SdkProvider which gets its defaults in a way that behaves like the AWS CLI does * * The AWS SDK for JS behaves slightly differently from the AWS CLI in a number of ways; see the * class `AwsCliCompatible` for the details. @@ -302,6 +308,7 @@ function parseHttpOptions(options: SdkHttpOptions) { debug('Using CA bundle path: %s', caBundlePath); config.httpOptions.agent = new https.Agent({ ca: readIfPossible(caBundlePath), + keepAlive: true, }); } diff --git a/packages/cdk-assets/bin/publish.ts b/packages/cdk-assets/bin/publish.ts index 2dc0911b41eb8..12a0e318d0f78 100644 --- a/packages/cdk-assets/bin/publish.ts +++ b/packages/cdk-assets/bin/publish.ts @@ -67,6 +67,8 @@ class DefaultAwsClient implements IAws { constructor(profile?: string) { // Force AWS SDK to look in ~/.aws/credentials and potentially use the configured profile. process.env.AWS_SDK_LOAD_CONFIG = '1'; + process.env.AWS_STS_REGIONAL_ENDPOINTS = 'regional'; + process.env.AWS_NODEJS_CONNECTION_REUSE_ENABLED = '1'; if (profile) { process.env.AWS_PROFILE = profile; }