Skip to content

Commit e07c8be

Browse files
committed
deal with legacy APIs
1 parent 0da2128 commit e07c8be

File tree

3 files changed

+90
-17
lines changed

3 files changed

+90
-17
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// This is a legacy wrapper for code from the aws-auth that we want to keep the signatures intact
2+
// We generally use two different patterns here:
3+
// - make a copy of the old code as is
4+
// - wrap the old code and add a deprecation warning
5+
// This way we can keep the old code running until the new code is fully ready
6+
// and can be used by the users that are ready to migrate
7+
// The old code will be removed in a future version of aws-cdk
8+
import type { AwsCredentialIdentityProvider, Logger, NodeHttpHandlerOptions } from '@smithy/types';
9+
import { SdkProvider as SdkProviderCurrentVersion } from './api/aws-auth/sdk-provider';
10+
import { CliIoHost } from './cli/io-host';
11+
12+
/**
13+
* Options for individual SDKs
14+
*/
15+
interface SdkHttpOptions {
16+
/**
17+
* Proxy address to use
18+
*
19+
* @default No proxy
20+
*/
21+
readonly proxyAddress?: string;
22+
23+
/**
24+
* A path to a certificate bundle that contains a cert to be trusted.
25+
*
26+
* @default No certificate bundle
27+
*/
28+
readonly caBundlePath?: string;
29+
}
30+
31+
/**
32+
* Options for the default SDK provider
33+
*/
34+
interface SdkProviderOptions {
35+
/**
36+
* Profile to read from ~/.aws
37+
*
38+
* @default - No profile
39+
*/
40+
readonly profile?: string;
41+
42+
/**
43+
* HTTP options for SDK
44+
*/
45+
readonly httpOptions?: SdkHttpOptions;
46+
47+
/**
48+
* The logger for sdk calls.
49+
*/
50+
readonly logger?: Logger;
51+
}
52+
53+
export class SdkProvider {
54+
public static async withAwsCliCompatibleDefaults(options: SdkProviderOptions = {}) {
55+
return SdkProviderCurrentVersion.withAwsCliCompatibleDefaults({
56+
...options,
57+
ioHelper: CliIoHost.instance().asIoHelper(),
58+
});
59+
}
60+
61+
public constructor(
62+
defaultCredentialProvider: AwsCredentialIdentityProvider,
63+
defaultRegion: string,
64+
requestHandler: NodeHttpHandlerOptions = {},
65+
logger?: Logger,
66+
) {
67+
return new SdkProviderCurrentVersion(defaultCredentialProvider, defaultRegion, requestHandler, CliIoHost.instance().asIoHelper(), logger);
68+
}
69+
}

packages/aws-cdk/lib/legacy-exports-source.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,31 @@
55

66
// Note: All type exports are in `legacy-exports.ts`
77
export * from './legacy-logging-source';
8-
export { deepClone, flatten, ifDefined, isArray, isEmpty, numberFromBool, partition, padLeft as leftPad, contentHash, deepMerge, lowerCaseFirstCharacter } from './util';
8+
9+
// API
10+
export { SdkProvider } from './legacy-aws-auth';
11+
export { setSdkTracing as enableTracing } from './api/aws-auth/tracing';
12+
export { cached } from './api/aws-auth/cached';
13+
export { CfnEvaluationException } from './api/cloudformation';
14+
export { CloudExecutable } from './api/cxapp/cloud-executable';
15+
export { execProgram } from './api/cxapp/exec';
16+
export { Deployments } from './api/deployments';
917
export { deployStack } from './api/deployments/deploy-stack';
10-
export { cli, exec } from './cli/cli';
11-
export { SdkProvider } from './api/aws-auth';
1218
export { PluginHost } from './api/plugin';
13-
export { Command, Configuration, PROJECT_CONTEXT } from './cli/user-configuration';
1419
export { Settings } from './api/settings';
1520
export { Bootstrapper } from './api/bootstrap';
16-
export { CloudExecutable } from './api/cxapp/cloud-executable';
17-
export { execProgram } from './api/cxapp/exec';
18-
export { RequireApproval } from './commands/diff';
19-
export { formatAsBanner } from './cli/util/console-formatters';
20-
export { setSdkTracing as enableTracing } from './api/aws-auth/tracing';
21-
export { aliases, command, describe } from './commands/docs';
22-
export { Deployments } from './api/deployments';
21+
22+
// CLI
23+
export { cli, exec } from './cli/cli';
2324
export { cliRootDir as rootDir } from './cli/root-dir';
25+
export { Command, Configuration, PROJECT_CONTEXT } from './cli/user-configuration';
26+
export { formatAsBanner } from './cli/util/console-formatters';
2427
export { latestVersionIfHigher, versionNumber } from './cli/version';
28+
29+
// Commands
30+
export { RequireApproval } from './commands/diff';
2531
export { availableInitTemplates } from './commands/init';
26-
export { cached } from './api/aws-auth/cached';
27-
export { CfnEvaluationException } from './api/cloudformation/evaluate-cloudformation-template';
28-
export { CredentialPlugins } from './api/aws-auth/credential-plugins';
29-
export { AwsCliCompatible } from './api/aws-auth/awscli-compatible';
32+
export { aliases, command, describe } from './commands/docs';
33+
34+
// util
35+
export { deepClone, flatten, ifDefined, isArray, isEmpty, numberFromBool, partition, padLeft as leftPad, contentHash, deepMerge, lowerCaseFirstCharacter } from './util';

packages/aws-cdk/lib/legacy-exports.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ export const {
7070
availableInitTemplates,
7171
cached,
7272
CfnEvaluationException,
73-
CredentialPlugins,
74-
AwsCliCompatible,
7573
withCorkedLogging,
7674
LogLevel,
7775
logLevel,

0 commit comments

Comments
 (0)