aws / aws/aws-cdk

(dynamodb): (TableOptions should not include partition key)

Open
#23,179 1 comment 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-dynamodb effort/small feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

While trying to create an L3 construct utilizing the dynamodb.Function method, we are running into the issue of needing to include a partition key for the dynamodb.TableOptions type. Since we are trying to handle some parameters before table creation (i.e encryption, PiTR, etc.), we have would like to have all other options be of the same type without including a partition key or the need to type out all possible options. This appears to be a bug as dynamodb.TableProps also is a type that forces the inclusion of a partition key. See picture below for desired implementation.

![image](https://user-images.githubusercontent.com/54596325/204918057-0a14d868-ab36-4d8e-8ea4-392302d22884.png)

For reference, dynamodb.TableOptions and dynamodb.TableProps should mirror lambda.FunctionOptions and lambda.FunctionProps respectively.

### Expected Behavior

Utilizing Table Options in an interface should not throw an error when a partition key is not provided, as all fields should be optional.

### Current Behavior

Utilizing Table Options in an interface should throws an error when a partition key is not provided, although all fields should be optional.

### Reproduction Steps

- Create a typescript interface with a variable of type dynamo.FunctionOptions
- Attempt to use that variable somewhere else in the repo
- Will see an error stating partition key is required

### Possible Solution

Remove partition key from dynamodb.TableOptions

### Additional Information/Context

_No response_

### CDK CLI Version

-

### Framework Version

_No response_

### Node.js Version

-

### OS

-

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the TableOptions and TableProps type definitions, then compare them with lambda.FunctionOptions and lambda.FunctionProps as the issue requests. Confirm that TableOptions accepts an interface without a partition key while TableProps retains the required table properties; no file or test path is named in the issue.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.