aws / aws/aws-sdk-js-codemod

[Feature]: Encode and Decode for Lamda calls

Open
#480 2 comments 0 reactions 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

### Template name

v2-to-v3

### Input code

```ts
const AWS = require("aws-sdk");

const lambda = new AWS.Lambda({ region: util_1.requireEnvironmentVariable('AWS_REGION') });
const sns = new AWS.SNS({ region: util_1.requireEnvironmentVariable('AWS_REGION') });

function getSnsPublishFunction(sns) {
return (input) => sns.publish(input).promise();
}

const params = {
FunctionName: lambdaName,
InvocationType: 'RequestResponse',
Payload: JSON.stringify(dbEvent),
};

const response = await lambda.invoke(params).promise();
const payload = JSON.parse(_.get(response, ['Payload']));
```

### Expected Output

```ts
const {
Lambda
} = require("@aws-sdk/client-lambda"),
{
SNS, PublishCommand
} = require("@aws-sdk/client-sns");

const lambda = new Lambda({ region: util_1.requireEnvironmentVariable('AWS_REGION') });
const sns = new SNS({ region: util_1.requireEnvironmentVariable('AWS_REGION') });

function getSnsPublishFunction(sns) {
return (input) => {
const command = new PublishCommand(input);
sns.send(command);
}
}

const params = {
FunctionName: lambdaName,
InvocationType: 'RequestResponse',
Payload: new TextEncoder().encode(JSON.stringify(dbEvent)),
};

const response = await lambda.invoke(params);
const payload = JSON.parse(new TextDecoder('utf-8').decode(_.get(response, ['Payload'])));
```

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

No source files, tests, or entry points are named. Start by locating the v2-to-v3 Lambda and SNS transformation logic, then inspect existing codemod fixtures for related command and payload conversions. Done means the shown Lambda and SNS calls are transformed to the expected AWS SDK v3 form with matching tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, node.js, typescript
Domain
cloud, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.