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

CDKTF tokens cannot be lifted directly #3289

Open eladb opened 1 year ago

eladb commented 1 year ago

I tried this:

bring "@cdktf/provider-aws" as aws;

let table = new aws.dynamodbTable.DynamodbTable(
  name: "mytable",
  readCapacity: 1,
  writeCapacity: 1,
  hashKey: "id",
  attribute: [ { name: "id", type: "S" } ],
);

test "print table name" {
  log(table.name);
}

This happened:

The environment variable captured is called SOMETHING_TOKEN1 while the emitted javascript code is SOMETHING_TOKEN3, which means this fails at runtime.

I expected this:

To work seamlessly

Is there a workaround?

Yes, you could assign the token to a preflight variable like this, and then it works:

bring "@cdktf/provider-aws" as aws;

let table = new aws.dynamodbTable.DynamodbTable(
  name: "mytable",
  readCapacity: 1,
  writeCapacity: 1,
  hashKey: "id",
  attribute: [ { name: "id", type: "S" } ],
);

let tableName = table.name;

test "print table name" {
  log(tableName);
}

Component

Compiler, SDK

Wing Version

No response

Wing Console Version

No response

Node.js Version

No response

Platform(s)

No response

Anything else?

We are planning to make lifting lazy which I suspect will solve this issue as well, so maybe no need to hack on the CDKTF side.

Community Notes

skorfmann commented 11 months ago

can confirm that the workaround worked for my case.

eladb commented 11 months ago

@skorfmann Do you think it makes sense to fix this upstream in CDKTF? Would you consider this a bug or is there some reason that makes it hard to fix?

skorfmann commented 10 months ago

Not really sure if these issues were related, but some of the lifting issues in the examples were fixed by some recent changes in Winglang https://github.com/winglang/examples/pull/18

skorfmann commented 9 months ago

Not really sure if these issues were related, but some of the lifting issues in the examples were fixed by some recent changes in Winglang winglang/examples#18

Wasn't related, still a thing.

@skorfmann Do you think it makes sense to fix this upstream in CDKTF? Would you consider this a bug or is there some reason that makes it hard to fix?

@eladb That was the token caching issue if I remember correctly?

github-actions[bot] commented 7 months ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 3 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 3 weeks ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!