aws-amplify / aws-amplify/amplify-cli

(gen2-migration) `generate` command doesn't handle all properties when generating lambda API triggers

Open
#14,569 1 comment 0 reactions 0 assignees View on GitHub
gen2-migration
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### How did you install the Amplify CLI?

npm install --no-save @aws-amplify/cli-internal-gen2-migration-experimental-alpha

### If applicable, what version of Node.js are you using?

_No response_

### Amplify CLI Version

0.6.0

### What operating system are you using?

Mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

### Describe the bug

When we generate the definitions for a lambda API trigger, we inspect the following CloudFormation template snippet:

```json
"LambdaEventSourceMappingProject": {
"Type": "AWS::Lambda::EventSourceMapping",
"DependsOn": [
"LambdaTriggerPolicyProject",
"LambdaExecutionRole"
],
"Properties": {
"BatchSize": 100,
"Enabled": true,
"EventSourceArn": {
"Fn::ImportValue": {
"Fn::Sub": "${apibackendonlyGraphQLAPIIdOutput}:GetAtt:ProjectTable:StreamArn"
}
},
"FunctionName": {
"Fn::GetAtt": [
"LambdaFunction",
"Arn"
]
},
"StartingPosition": "LATEST"
}
},
```

This created on `amplify push` and located in the function specific directory of the `amplify/backend` folder.

Currently, we don't extract all the information we should:

- `StartingPosition` is always hardcoded to `LATEST`. We need to validate this is correct or whether it can have a different value.
- `BatchSize` is not extracted at all and we just allow the default CDK value to take affect. This value doesn't necessary match whats in this template.

### Expected behavior

We should set the values of the mentioned properties based on what exists in the template.

### Reproduction steps

Configure an API lambda trigger. We have that in the discussions app.

### Project Identifier

_No response_

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

### Before submitting, please confirm:

- [x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [x] I have removed any sensitive information from my code snippets and submission.

Contributor guide

Open the contributing guide

Research direction

Start in the gen2-migration generator that reads AWS::Lambda::EventSourceMapping resources from the function-specific amplify/backend directory. Compare its handling of StartingPosition and BatchSize with the CloudFormation template shown, using the discussions app reproduction. Done means generated definitions preserve the template values rather than relying on defaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cli, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.