From 4d9a9b9c8d192176cdeaaf887115e6271023fc80 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 20 Oct 2023 09:54:28 -0700 Subject: [PATCH] Support CognitoIdentityCredentials --- .../__fixtures__/credentials/cognito-identity.input.js | 3 +++ .../__fixtures__/credentials/cognito-identity.output.js | 6 ++++++ src/transforms/v2-to-v3/config/AWS_CREDENTIALS_MAP.ts | 1 + 3 files changed, 10 insertions(+) create mode 100644 src/transforms/v2-to-v3/__fixtures__/credentials/cognito-identity.input.js create mode 100644 src/transforms/v2-to-v3/__fixtures__/credentials/cognito-identity.output.js diff --git a/src/transforms/v2-to-v3/__fixtures__/credentials/cognito-identity.input.js b/src/transforms/v2-to-v3/__fixtures__/credentials/cognito-identity.input.js new file mode 100644 index 000000000..5f7be3c97 --- /dev/null +++ b/src/transforms/v2-to-v3/__fixtures__/credentials/cognito-identity.input.js @@ -0,0 +1,3 @@ +import AWS from "aws-sdk"; + +new AWS.CognitoIdentityCredentials(); \ No newline at end of file diff --git a/src/transforms/v2-to-v3/__fixtures__/credentials/cognito-identity.output.js b/src/transforms/v2-to-v3/__fixtures__/credentials/cognito-identity.output.js new file mode 100644 index 000000000..b81904f5d --- /dev/null +++ b/src/transforms/v2-to-v3/__fixtures__/credentials/cognito-identity.output.js @@ -0,0 +1,6 @@ +import { fromCognitoIdentity } from "@aws-sdk/credential-providers"; + +// JS SDK v3 switched to credential providers to functions instead of objects. +// This is the closest approximation from codemod of what your application needs. +// Reference: https://www.npmjs.com/package/@aws-sdk/credential-providers +fromCognitoIdentity(); \ No newline at end of file diff --git a/src/transforms/v2-to-v3/config/AWS_CREDENTIALS_MAP.ts b/src/transforms/v2-to-v3/config/AWS_CREDENTIALS_MAP.ts index 1bf539b37..e75303aa5 100644 --- a/src/transforms/v2-to-v3/config/AWS_CREDENTIALS_MAP.ts +++ b/src/transforms/v2-to-v3/config/AWS_CREDENTIALS_MAP.ts @@ -3,6 +3,7 @@ */ export const AWS_CREDENTIALS_MAP: Record = { ChainableTemporaryCredentials: "fromTemporaryCredentials", + CognitoIdentityCredentials: "fromCognitoIdentity", EC2MetadataCredentials: "fromInstanceMetadata", ECSCredentials: "fromContainerMetadata", EnvironmentCredentials: "fromEnv",