Skip to content

Commit

Permalink
Basic transformation for AWS.Config constructor (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Oct 25, 2023
1 parent c0e3384 commit 734411c
Show file tree
Hide file tree
Showing 59 changed files with 437 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/hungry-camels-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": minor
---

Basic transformation for AWS.Config constructor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
computeChecksums: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// The key computeChecksums is no longer supported in v3, and can be removed.
// @deprecated Applicable commands of S3 will automatically compute the MD5 checksums.
computeChecksums: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
convertResponseTypes: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// The key convertResponseTypes is no longer supported in v3, and can be removed.
// @deprecated Not type-safe. It doesn't convert time stamp or base64 binaries from the JSON response.
convertResponseTypes: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
correctClockSkew: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// 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
@@ -0,0 +1,8 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
credentials: {
accessKeyId: "AKID",
secretAccessKey: "SECRET"
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config = {
credentials: {
accessKeyId: "AKID",
secretAccessKey: "SECRET"
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
endpointCacheSize: 100
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {
endpointCacheSize: 100
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
endpointDiscoveryEnabled: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {
endpointDiscoveryEnabled: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
hostPrefixEnabled: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// The key hostPrefixEnabled is no longer supported in v3, and can be removed.
// @deprecated The hostname prefix is automatically inserted when necessary.
hostPrefixEnabled: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
httpOptions: {
connectTimeout: 1000,
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const config = {
// The transformation for httpOptions is not implemented.
// Refer to UPGRADING.md on aws-sdk-js-v3 for changes needed.
// Please create/upvote feature request on aws-sdk-js-codemod for httpOptions.
httpOptions: {
connectTimeout: 1000,
}
};
5 changes: 5 additions & 0 deletions src/transforms/v2-to-v3/__fixtures__/config/logger.input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
logger: console
});
3 changes: 3 additions & 0 deletions src/transforms/v2-to-v3/__fixtures__/config/logger.output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {
logger: console
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
maxRedirects: 10
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// The key maxRedirects is no longer supported in v3, and can be removed.
// @deprecated SDK does not follow redirects to avoid unintentional cross-region requests.
maxRedirects: 10
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
maxRetries: 5
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// The key maxRetries is renamed to maxAttempts.
// The value of maxAttempts needs to be maxRetries + 1.
maxAttempts: 5
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
paramValidation: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// The key paramValidation is no longer supported in v3, and can be removed.
// @deprecated The SDK no longer validates input parameters.
paramValidation: true
};
5 changes: 5 additions & 0 deletions src/transforms/v2-to-v3/__fixtures__/config/region.input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
region: "us-east-1"
});
3 changes: 3 additions & 0 deletions src/transforms/v2-to-v3/__fixtures__/config/region.output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {
region: "us-east-1"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
retryDelayOptions: { base: 300 }
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config = {
// Reference: https://www.npmjs.com/package/@smithy/util-retry
// The key retryDelayOptions is no longer supported in v3, and can be removed.
// @deprecated The SDK supports more flexible retry strategies in retryStrategy option.
retryDelayOptions: { base: 300 }
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
s3BucketEndpoint: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const config = {
// The key s3BucketEndpoint is renamed to bucketEndpoint.
bucketEndpoint: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
s3ForcePathStyle: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const config = {
// The key s3ForcePathStyle is renamed to forcePathStyle.
forcePathStyle: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
s3UsEast1RegionalEndpoint: "legacy"
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config = {
// S3 client will always use regional endpoint if region is set to "us-east-1".
// The key s3UsEast1RegionalEndpoint is no longer supported in v3, and can be removed.
// @deprecated Set region to "aws-global" to send requests to S3 global endpoint.
s3UsEast1RegionalEndpoint: "legacy"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
s3UseArnRegion: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const config = {
// The key s3UseArnRegion is renamed to useArnRegion.
useArnRegion: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
signatureCache: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// The key signatureCache is no longer supported in v3, and can be removed.
// @deprecated SDK always caches the hashed signing keys.
signatureCache: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
signatureVersion: "v2"
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
// The key signatureVersion is no longer supported in v3, and can be removed.
// @deprecated SDK v3 only supports signature v4.
signatureVersion: "v2"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
sslEnabled: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const config = {
// The key sslEnabled is renamed to tls.
tls: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
stsRegionalEndpoints: "legacy"
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config = {
// STS client will always use regional endpoints if set to a specific region.
// The key stsRegionalEndpoints is no longer supported in v3, and can be removed.
// @deprecated Set region to "aws-global" to send requests to STS global endpoint.
stsRegionalEndpoints: "legacy"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
systemClockOffset: 100
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {
systemClockOffset: 100
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
useAccelerateEndpoint: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {
useAccelerateEndpoint: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
useDualstackEndpoint: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {
useDualstackEndpoint: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AWS from "aws-sdk";

const config = new AWS.Config({
useFipsEndpoint: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {
useFipsEndpoint: true
};
Loading

0 comments on commit 734411c

Please sign in to comment.