Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-carrots-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Transform config inside client initialization
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import AWS = require("aws-sdk");

const ddbClient = new AWS.DynamoDB({ region: "us-west-2" });
const ddbClient = new AWS.DynamoDB();
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new AWS.STS({ region: "us-west-2" });
const stsClient = new AWS.STS();
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();

const lambdaClient = new AWS.Lambda({ region: "us-west-2" });
const lambdaClient = new AWS.Lambda();
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
.invoke(invokeInput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import STS = AWS_client_sts.STS;
import GetCallerIdentityCommandOutput = AWS_client_sts.GetCallerIdentityCommandOutput;
import GetCallerIdentityCommandInput = AWS_client_sts.GetCallerIdentityCommandInput;

const ddbClient = new DynamoDB({ region: "us-west-2" });
const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);

const lambdaClient = new Lambda({ region: "us-west-2" });
const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import AWS from "aws-sdk";

const ddbClient = new AWS.DynamoDB({ region: "us-west-2" });
const ddbClient = new AWS.DynamoDB();
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new AWS.STS({ region: "us-west-2" });
const stsClient = new AWS.STS();
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();

const lambdaClient = new AWS.Lambda({ region: "us-west-2" });
const lambdaClient = new AWS.Lambda();
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
.invoke(invokeInput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";

const ddbClient = new DynamoDB({ region: "us-west-2" });
const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);

const lambdaClient = new Lambda({ region: "us-west-2" });
const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import DynamoDB, { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dyn
import Lambda, { InvocationRequest, InvocationResponse } from "aws-sdk/clients/lambda";
import STS, { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";

const ddbClient = new DynamoDB({ region: "us-west-2" });
const ddbClient = new DynamoDB();
const listTablesInput: ListTablesInput = { Limit: 10 };
const listTablesOutput: ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new STS({ region: "us-west-2" });
const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityRequest = {};
const getCallerIdentityOutput: GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();

const lambdaClient = new Lambda({ region: "us-west-2" });
const lambdaClient = new Lambda();
const invokeInput: InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: InvocationResponse = await lambdaClient
.invoke(invokeInput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";

const ddbClient = new DynamoDB({ region: "us-west-2" });
const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);

const lambdaClient = new Lambda({ region: "us-west-2" });
const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import DynamoDB = require("aws-sdk/clients/dynamodb");
import Lambda = require("aws-sdk/clients/lambda");
import STS = require("aws-sdk/clients/sts");

const ddbClient = new DynamoDB({ region: "us-west-2" });
const ddbClient = new DynamoDB();
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new STS({ region: "us-west-2" });
const stsClient = new STS();
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();

const lambdaClient = new Lambda({ region: "us-west-2" });
const lambdaClient = new Lambda();
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
.invoke(invokeInput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import STS = AWS_client_sts.STS;
import GetCallerIdentityCommandOutput = AWS_client_sts.GetCallerIdentityCommandOutput;
import GetCallerIdentityCommandInput = AWS_client_sts.GetCallerIdentityCommandInput;

const ddbClient = new DynamoDB({ region: "us-west-2" });
const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);

const lambdaClient = new Lambda({ region: "us-west-2" });
const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { DynamoDB, Lambda, STS } from "aws-sdk";

const ddbClient = new DynamoDB({ region: "us-west-2" });
const ddbClient = new DynamoDB();
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new STS({ region: "us-west-2" });
const stsClient = new STS();
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();

const lambdaClient = new Lambda({ region: "us-west-2" });
const lambdaClient = new Lambda();
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
.invoke(invokeInput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";

const ddbClient = new DynamoDB({ region: "us-west-2" });
const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);

const lambdaClient = new Lambda({ region: "us-west-2" });
const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
5 changes: 5 additions & 0 deletions src/transforms/v2-to-v3/__fixtures__/config/client.input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const client = new AWS.DynamoDB({
correctClockSkew: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DynamoDB } from "@aws-sdk/client-dynamodb";

const client = new DynamoDB({
// The key correctClockSkew is no longer supported in v3, and can be removed.
// @deprecated The clock skew correction is applied by default.
correctClockSkew: true
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AWS from "aws-sdk";

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();
const uploadParams = {
Body: "BODY",
Bucket: "Bucket",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AWS from "aws-sdk";

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();
const uploadParams = {
Body: "BODY",
Bucket: "Bucket",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AWS from "aws-sdk";

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();
const uploadParams = {
Body: "BODY",
Bucket: "Bucket",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AWS from "aws-sdk";

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();
const uploadParams = {
Body: "BODY",
Bucket: "Bucket",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AWS = require("aws-sdk");

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();
await client.upload({
Body: "BODY",
Bucket: "Bucket",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Upload = AWS_lib_storage.Upload;
import AWS_client_s3 = require("@aws-sdk/client-s3");
import S3 = AWS_client_s3.S3;

const client = new S3({ region: "REGION" });
const client = new S3();
await new Upload({
client,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AWS from "aws-sdk";

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();
await client.upload({
Body: "BODY",
Bucket: "Bucket",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Upload } from "@aws-sdk/lib-storage";
import { S3 } from "@aws-sdk/client-s3";

const client = new S3({ region: "REGION" });
const client = new S3();
await new Upload({
client,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const S3 = require("aws-sdk").S3;

const client = new S3({ region: "REGION" });
const client = new S3();
await client.upload({
Body: "BODY",
Bucket: "Bucket",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
S3
} = require("@aws-sdk/client-s3");

const client = new S3({ region: "REGION" });
const client = new S3();
await new Upload({
client,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AWS = require("aws-sdk");

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();
await client.upload({
Body: "BODY",
Bucket: "Bucket",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
S3
} = require("@aws-sdk/client-s3");

const client = new S3({ region: "REGION" });
const client = new S3();
await new Upload({
client,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AWS from "aws-sdk";

const client = new AWS.DynamoDB({ region: "REGION" });
const client = new AWS.DynamoDB();
// Used for testing. DynamoDB does not have upload API.
await client.upload({}).promise();
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DynamoDB } from "@aws-sdk/client-dynamodb";

const client = new DynamoDB({ region: "REGION" });
const client = new DynamoDB();
// Used for testing. DynamoDB does not have upload API.
await client.upload({});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AWS from "aws-sdk";

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();

const uploadParams = {
Body: "BODY",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Upload } from "@aws-sdk/lib-storage";
import { S3 } from "@aws-sdk/client-s3";

const client = new S3({ region: "REGION" });
const client = new S3();

const uploadParams = {
Body: "BODY",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AWS from "aws-sdk";

const client = new AWS.S3({ region: "REGION" });
const client = new AWS.S3();
await client
.upload(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Upload } from "@aws-sdk/lib-storage";
import { S3 } from "@aws-sdk/client-s3";

const client = new S3({ region: "REGION" });
const client = new S3();
await new Upload({
client,

Expand Down
Loading