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

compiler: cdktf tokens in resource names #3908

Open skorfmann opened 10 months ago

skorfmann commented 10 months ago

I tried this:

bring cloud;
bring "@cdktf/provider-null" as nullish;

let provider = new nullish.provider.NullProvider();
let resource = new nullish.resource.Resource();
new cloud.Bucket() as "foo.${resource.getStringAttribute("id")}";

This is a made up example, the crucial part is to reference a cdktf token in the as definition.

This happened:

cat ./target/main.tfaws/main.tf.json | jq ".resource.aws_s3_bucket"

{
  "fooTfTokenTOKEN1": {
    "//": {
      "metadata": {
        "path": "root/Default/Default/foo.${null_resource.nullishresourceResource.id}/Default",
        "uniqueId": "fooTfTokenTOKEN1"
      }
    },
    "bucket_prefix": "foo-tftoken-token-1--c8d4ce24-",
    "force_destroy": false
  }
}

I expected this:

either resolve the token somehow or throw an error that this is not allowed. The latter was done in cdktf at some point, but don't recall the reasoning https://github.com/hashicorp/terraform-cdk/issues/1068

Is there a workaround?

No response

Component

Compiler

Wing Version

0.25.30

Node.js Version

v18.17.0

Platform(s)

MacOS

Anything else?

No response

Community Notes

github-actions[bot] commented 8 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 6 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 1 month 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!