Skip to content

Commit

Permalink
Add comment about credentials transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Oct 20, 2023
1 parent 4ab5459 commit e5cd234
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import AWS from "aws-sdk";

new AWS.ChainableTemporaryCredentials({
params: { RoleArn: "RoleA" },
masterCredentials: existingCredentials,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { fromTemporaryCredentials } 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
fromTemporaryCredentials({
params: { RoleArn: "RoleA" },
masterCredentials: existingCredentials,
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import AWS from "aws-sdk";

const credentials = new AWS.EC2MetadataCredentials();
new AWS.EC2MetadataCredentials();
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { fromInstanceMetadata } from "@aws-sdk/credential-providers";

const credentials = fromInstanceMetadata();
// 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
fromInstanceMetadata();
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import AWS from "aws-sdk";

const credentials = new AWS.ECSCredentials();
new AWS.ECSCredentials();
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { fromContainerMetadata } from "@aws-sdk/credential-providers";

const credentials = fromContainerMetadata();
// 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
fromContainerMetadata();
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import AWS from "aws-sdk";

const credentials = new AWS.EnvironmentCredentials("AWS");
new AWS.EnvironmentCredentials("AWS");
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { fromEnv } from "@aws-sdk/credential-providers";

const credentials = fromEnv("AWS");
// 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
fromEnv("AWS");

This file was deleted.

This file was deleted.

16 changes: 15 additions & 1 deletion src/transforms/v2-to-v3/apis/replaceAwsCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,21 @@ export const replaceAwsCredentials = (
packageName: "@aws-sdk/credential-providers",
});
credsNewExpressions.replaceWith(({ node }) =>
j.callExpression(j.identifier(v3ProviderName), node.arguments)
j.callExpression.from({
callee: j.identifier(v3ProviderName),
comments: [
j.commentLine(
" JS SDK v3 switched to credential providers to functions instead of objects."
),
j.commentLine(
" This is the closest approximation from codemod of what your application needs."
),
j.commentLine(
" Reference: https://www.npmjs.com/package/@aws-sdk/credential-providers"
),
],
arguments: node.arguments,
})
);
}
}
Expand Down

0 comments on commit e5cd234

Please sign in to comment.