winglang / wing

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

`dynamodb` - `globalSecondaryIndex` and `timeToLiveAttribute` do nothing in `tf-aws` #6207

Open meirdev opened 2 months ago

meirdev commented 2 months ago

I tried this:

bring dynamodb;

let a = new dynamodb.Table(
  attributes: [
    { name: "Attr1", type: "S" },
    { name: "Attr2", type: "S" },
    { name: "TTL", type: "N" },
  ],
  hashKey: "Attr1",
  globalSecondaryIndex: [
    {
      hashKey: "Attr2",
      name: "GSI",
      projectionType: "ALL"
    }
  ],
  timeToLiveAttribute: "TTL"
);

This happened:

compiled (-t tf-aws) to:

...
    "aws_dynamodb_table": {
      "Table_Table_tfaws_DynamodbTable_11E7B97E": {
        "//": {
          "metadata": {
            "path": "root/Default/Default/Table/Table_tfaws/DynamodbTable",
            "uniqueId": "Table_Table_tfaws_DynamodbTable_11E7B97E"
          }
        },
        "attribute": [
          {
            "name": "Attr1",
            "type": "S"
          },
          {
            "name": "Attr2",
            "type": "S"
          },
          {
            "name": "TTL",
            "type": "N"
          }
        ],
        "billing_mode": "PAY_PER_REQUEST",
        "hash_key": "Attr1",
        "name": "Table-Table_tfaws-02507406",
        "stream_enabled": true,
        "stream_view_type": "NEW_AND_OLD_IMAGES"
      }
    },
...

I expected this:

GSI and TTL attributes in the terraform file

Is there a workaround?

No response

Anything else?

This is implemented in sim:

https://github.com/winglang/winglibs/blob/09de4ab59038dbe3c215ca5878c955db9de9ac56/dynamodb/dynamodb.sim.w#L103

https://github.com/winglang/winglibs/blob/09de4ab59038dbe3c215ca5878c955db9de9ac56/dynamodb/dynamodb.sim.w#L174

Wing Version

0.66.8

Node.js Version

v20.11.0

Platform(s)

MacOS

Community Notes

ekeren commented 2 months ago

@skyrpex FYI