You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected the CDKTF (Typescript) to use the current path to read the file. This is happening to any CDKTF thing, like TF functions (e.g. file, filemd5), AWS resources (e.g. aws_s3_object).
Instead of considering the current folder (./), it's considering a subfolder (./cdktf.out/stacks/myproject-dev). So, for me to read any files in the current folder (e.g. under the ./templates/), I would need to do ../../../templates/.
But, if I do this const filePath = path.resolve(file); and pass the filePath it will work fine because it will have the full path. So, only the TF stuff considers the path ./cdktf.out/stacks/<stackName>.
This issue took me a while to figure this out. I couldn't use the full path since I'm uploading a file to S3 and the state will change if I run from my machine vs a colleague's machine vs CI/CD pipelines. I could, of course, use the lifecycle ignore-changes, but it's just a workaround and I would rather not do it.
This behaviour doesn't happen on TF, only in CDKTF.
Actual Behavior
│ Invalid value for "path" parameter: no file exists at
│ "templates/my-template.json"; this function works only with
│ files that are distributed as part of the configuration source code, so if
│ this file will be created by a resource in this configuration you must
│ instead obtain this result from an attribute of that resource.
Steps to Reproduce
Create a sample file under the ./templates
import{Fn}from'cdktf';
...
/*The way to solve this is to go up three directoriesconst file = `../../../templates/my-template.json`;IMO, doing like 'const filePath = path.resolve(file);' is just a terrible workaround as you'll also have to use ignoreChanges.*/constfile='templates/my-template.json'// or const file = './templates/my-template.json'constetag=Fn.filemd5(file);newS3Object(this,`s3-object-${file}`,{bucket: s3Created.id,key: file,source: file,
etag,
tags,});
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
The text was updated successfully, but these errors were encountered:
Expected Behavior
I expected the CDKTF (Typescript) to use the current path to read the file. This is happening to any CDKTF thing, like TF functions (e.g. file, filemd5), AWS resources (e.g. aws_s3_object).
Instead of considering the current folder (
./
), it's considering a subfolder (./cdktf.out/stacks/myproject-dev
). So, for me to read any files in the current folder (e.g. under the./templates/
), I would need to do../../../templates/
.But, if I do this
const filePath = path.resolve(file);
and pass thefilePath
it will work fine because it will have the full path. So, only the TF stuff considers the path./cdktf.out/stacks/<stackName>
.This issue took me a while to figure this out. I couldn't use the full path since I'm uploading a file to S3 and the state will change if I run from my machine vs a colleague's machine vs CI/CD pipelines. I could, of course, use the lifecycle ignore-changes, but it's just a workaround and I would rather not do it.
This behaviour doesn't happen on TF, only in CDKTF.
Actual Behavior
Steps to Reproduce
./templates
Versions
Providers
Gist
No response
Possible Solutions
No response
Workarounds
No response
Anything Else?
No response
References
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: