Skip to content

Commit f28eaa8

Browse files
authored
Transform global imports from 'aws-sdk/lib/core' (#852)
1 parent 98790a3 commit f28eaa8

10 files changed

+42
-0
lines changed

.changeset/wet-hairs-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Transform global imports from 'aws-sdk/lib/core'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import AWS from "aws-sdk/lib/core";
2+
3+
new AWS.EnvironmentCredentials();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { fromEnv } from "@aws-sdk/credential-providers";
2+
3+
// JS SDK v3 switched credential providers from classes to functions.
4+
// This is the closest approximation from codemod of what your application needs.
5+
// Reference: https://www.npmjs.com/package/@aws-sdk/credential-providers
6+
fromEnv();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const AWS = require("aws-sdk/lib/core");
2+
3+
new AWS.EnvironmentCredentials();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { fromEnv } = require("@aws-sdk/credential-providers");
2+
3+
// JS SDK v3 switched credential providers from classes to functions.
4+
// This is the closest approximation from codemod of what your application needs.
5+
// Reference: https://www.npmjs.com/package/@aws-sdk/credential-providers
6+
fromEnv();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { EnvironmentCredentials } from "aws-sdk/lib/core";
2+
3+
new EnvironmentCredentials();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { fromEnv } from "@aws-sdk/credential-providers";
2+
3+
// JS SDK v3 switched credential providers from classes to functions.
4+
// This is the closest approximation from codemod of what your application needs.
5+
// Reference: https://www.npmjs.com/package/@aws-sdk/credential-providers
6+
fromEnv();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { EnvironmentCredentials } = require("aws-sdk/lib/core");
2+
3+
new EnvironmentCredentials();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { fromEnv } = require("@aws-sdk/credential-providers");
2+
3+
// JS SDK v3 switched credential providers from classes to functions.
4+
// This is the closest approximation from codemod of what your application needs.
5+
// Reference: https://www.npmjs.com/package/@aws-sdk/credential-providers
6+
fromEnv();

src/transforms/v2-to-v3/transformer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const transformer = async (file: FileInfo, api: API) => {
5555
}
5656

5757
replaceDeepImport(j, source, { fromPath: "aws-sdk/global", toPath: PACKAGE_NAME });
58+
replaceDeepImport(j, source, { fromPath: "aws-sdk/lib/core", toPath: PACKAGE_NAME });
5859
replaceDeepImport(j, source, { fromPath: "aws-sdk/clients/all", toPath: PACKAGE_NAME });
5960

6061
const v2GlobalName = getGlobalNameFromModule(j, source);

0 commit comments

Comments
 (0)