compiler: cdktf tokens in resource names
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 215
- Avg merge
- 2h 9m
- Merged PRs (30d)
- 27
Description
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
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example from the issue and inspect target/main.tfaws/main.tf.json, focusing on the generated resource name and metadata. Trace the compiler's handling of cdktf tokens in the as definition; done means the token is resolved in the name or the compiler reports that this usage is unsupported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- terraform
- Domain
- compilers, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100