Skip to content

Commit 8d1d3bb

Browse files
authored
Transform config inside client initialization (#649)
1 parent 3936aae commit 8d1d3bb

File tree

76 files changed

+173
-137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+173
-137
lines changed

.changeset/calm-carrots-cheat.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 config inside client initialization

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/global-import-equals.input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import AWS = require("aws-sdk");
22

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

9-
const stsClient = new AWS.STS({ region: "us-west-2" });
9+
const stsClient = new AWS.STS();
1010
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
1111
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
1212
.getCallerIdentity(getCallerIdentityInput)
1313
.promise();
1414

15-
const lambdaClient = new AWS.Lambda({ region: "us-west-2" });
15+
const lambdaClient = new AWS.Lambda();
1616
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
1717
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
1818
.invoke(invokeInput)

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/global-import-equals.output.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import STS = AWS_client_sts.STS;
1111
import GetCallerIdentityCommandOutput = AWS_client_sts.GetCallerIdentityCommandOutput;
1212
import GetCallerIdentityCommandInput = AWS_client_sts.GetCallerIdentityCommandInput;
1313

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

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

24-
const lambdaClient = new Lambda({ region: "us-west-2" });
24+
const lambdaClient = new Lambda();
2525
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
2626
const invokeOutput: InvokeCommandOutput = await lambdaClient
2727
.invoke(invokeInput);

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/global-import.input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import AWS from "aws-sdk";
22

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

9-
const stsClient = new AWS.STS({ region: "us-west-2" });
9+
const stsClient = new AWS.STS();
1010
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
1111
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
1212
.getCallerIdentity(getCallerIdentityInput)
1313
.promise();
1414

15-
const lambdaClient = new AWS.Lambda({ region: "us-west-2" });
15+
const lambdaClient = new AWS.Lambda();
1616
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
1717
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
1818
.invoke(invokeInput)

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/global-import.output.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-
22
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
33
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
44

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

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

15-
const lambdaClient = new Lambda({ region: "us-west-2" });
15+
const lambdaClient = new Lambda();
1616
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
1717
const invokeOutput: InvokeCommandOutput = await lambdaClient
1818
.invoke(invokeInput);

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/service-import-deep.input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import DynamoDB, { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dyn
22
import Lambda, { InvocationRequest, InvocationResponse } from "aws-sdk/clients/lambda";
33
import STS, { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";
44

5-
const ddbClient = new DynamoDB({ region: "us-west-2" });
5+
const ddbClient = new DynamoDB();
66
const listTablesInput: ListTablesInput = { Limit: 10 };
77
const listTablesOutput: ListTablesOutput = await ddbClient
88
.listTables(listTablesInput)
99
.promise();
1010

11-
const stsClient = new STS({ region: "us-west-2" });
11+
const stsClient = new STS();
1212
const getCallerIdentityInput: GetCallerIdentityRequest = {};
1313
const getCallerIdentityOutput: GetCallerIdentityResponse = await stsClient
1414
.getCallerIdentity(getCallerIdentityInput)
1515
.promise();
1616

17-
const lambdaClient = new Lambda({ region: "us-west-2" });
17+
const lambdaClient = new Lambda();
1818
const invokeInput: InvocationRequest = { FunctionName: "my-function" };
1919
const invokeOutput: InvocationResponse = await lambdaClient
2020
.invoke(invokeInput)

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/service-import-deep.output.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-
22
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
33
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
44

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

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

15-
const lambdaClient = new Lambda({ region: "us-west-2" });
15+
const lambdaClient = new Lambda();
1616
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
1717
const invokeOutput: InvokeCommandOutput = await lambdaClient
1818
.invoke(invokeInput);

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/service-import-equals.input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import DynamoDB = require("aws-sdk/clients/dynamodb");
22
import Lambda = require("aws-sdk/clients/lambda");
33
import STS = require("aws-sdk/clients/sts");
44

5-
const ddbClient = new DynamoDB({ region: "us-west-2" });
5+
const ddbClient = new DynamoDB();
66
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
77
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
88
.listTables(listTablesInput)
99
.promise();
1010

11-
const stsClient = new STS({ region: "us-west-2" });
11+
const stsClient = new STS();
1212
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
1313
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
1414
.getCallerIdentity(getCallerIdentityInput)
1515
.promise();
1616

17-
const lambdaClient = new Lambda({ region: "us-west-2" });
17+
const lambdaClient = new Lambda();
1818
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
1919
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
2020
.invoke(invokeInput)

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/service-import-equals.output.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import STS = AWS_client_sts.STS;
1111
import GetCallerIdentityCommandOutput = AWS_client_sts.GetCallerIdentityCommandOutput;
1212
import GetCallerIdentityCommandInput = AWS_client_sts.GetCallerIdentityCommandInput;
1313

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

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

24-
const lambdaClient = new Lambda({ region: "us-west-2" });
24+
const lambdaClient = new Lambda();
2525
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
2626
const invokeOutput: InvokeCommandOutput = await lambdaClient
2727
.invoke(invokeInput);

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/service-import.input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { DynamoDB, Lambda, STS } from "aws-sdk";
22

3-
const ddbClient = new DynamoDB({ region: "us-west-2" });
3+
const ddbClient = new DynamoDB();
44
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
55
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
66
.listTables(listTablesInput)
77
.promise();
88

9-
const stsClient = new STS({ region: "us-west-2" });
9+
const stsClient = new STS();
1010
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
1111
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
1212
.getCallerIdentity(getCallerIdentityInput)
1313
.promise();
1414

15-
const lambdaClient = new Lambda({ region: "us-west-2" });
15+
const lambdaClient = new Lambda();
1616
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
1717
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
1818
.invoke(invokeInput)

0 commit comments

Comments
 (0)