aws / aws/aws-sdk-js-codemod

[Feature]: Replace AWS.Credentials new instance creation with the credentials object

Open
#687 1 comment 1 reaction 0 assignees View on GitHub
enhancement p2
Dominant language
TypeScript
Stars
89
Forks
13
Avg merge
9h 59m
Merged PRs (30d)
1

Description

### Self-service

- [ ] I'd be willing to implement this feature

### Problem

The new instance creation of AWS.Credentials class is not replaced.

Examples
```js
import AWS from "aws-sdk";

// credentials object as options
const creds = new AWS.Credentials({
accessKeyId: 'akid',
secretAccessKey: 'secret',
sessionToken: 'session',
});
```

```js
import AWS from "aws-sdk";

// credentials as options
const creds = new AWS.Credentials('akid', 'secret', 'session');
```

### Solution

Replace new instance with Credentials object with a comment that it's the best guess from codemod.

```js
const creds = {
accessKeyId: 'akid',
secretAccessKey: 'secret',
sessionToken: 'session',
};
```

### Alternatives

Wait for JS SDK v3 to provide fromStatic credential provider https://github.com/aws/aws-sdk-js-v3/issues/5452

### Additional context

Examples usages in production:
* https://github.com/ToolJet/ToolJet/blob/bea8d1bd25075503e0873ddc74a0b271be1ce071/plugins/packages/amazonses/lib/index.ts#L80-L87
* https://github.com/transloadit/uppy/blob/43178f1c4f7369b4275c4e7aa6b7cdc827ff8420/bin/upload-to-cdn.js#L112-L115

Contributor guide

Open the contributing guide

Research direction

The issue names no repository file, test, or entry point; start by locating the transform that handles AWS.Credentials construction and its existing tests. Compare the two constructor forms described above, then verify that the generated object and best-guess comment match the requested examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.