winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.06k stars 198 forks source link

DynamoDB WingLib will not deploy to AWS without startingPosition, but this is not documented #7178

Closed boyney123 closed 3 weeks ago

boyney123 commented 1 month ago

Use Case

Using the WingLib for DynamoDB trying to deploy my application to AWS with terraform. Says the startingPosition is required, but nothing states this in the documentation or examples.

Proposed Solution

Add missing docs.

Implementation Notes

No response

Component

No response

Community Notes

Chriscbr commented 1 month ago

@boyney123 Can you include an example or the error message in full?

boyney123 commented 1 month ago

Yeah sure

here is the error

 Error: creating Lambda Event Source Mapping (arn:aws:dynamodb:us-east-1:654654508474:table/SpacesTable/stream/2024-09-30T10:24:17.260): operation error Lambda: CreateEventSourceMapping, https response error StatusCode: 400, RequestID: 497bc8b2-d962-4f09-bb50-187a59a3e650, InvalidParameterValueException: 1 validation error detected: Value null at 'startingPosition' failed to satisfy constraint: Member must not be null.

So a DDB stream to a Lambda function

This example won't work as the startingPosition is not defined.

db.setStreamConsumer(inflight (record: dynamodb.StreamRecord) => {
     // LOGIC....
});

This works

db.setStreamConsumer(inflight (record: dynamodb.StreamRecord) => {
     // LOGIC....
}, { startingPosition: "LATEST" });

@Chriscbr what you think? Should we default this value for folks in in the winglib? Maybe default to LATEST? Or somehow give them errors to help them at least?

Chriscbr commented 1 month ago

Default to LATEST sounds reasonable.

boyney123 commented 1 month ago

Will try and make the change

boyney123 commented 1 month ago

OK PR open https://github.com/winglang/winglibs/pull/324

boyney123 commented 3 weeks ago

This is now merged, closing this issue