terraform-cdk icon indicating copy to clipboard operation
terraform-cdk copied to clipboard

CDKTF userdata path: examples does not work in aws launch template

Open rpatidar opened this issue 1 year ago • 0 comments

Expected Behavior

cdk synth should work and should not fail.

Actual Behavior

i have tried various options placing the file at differrent folders it always return

Failure1

                       │ Error: Invalid function argument
                       │
                       │   on cdk.tf.json line 94, in resource.aws_launch_template.MyService-LTConstruct-test (MyService-LTConstruct-test):
                       │   94:         "user_data": "${filebase64(\"scripts/myscript.sh\")}",
                       │     ├────────────────
                       │     │ while calling filebase64(path)

Failue2:

                       │ Error: Invalid function argument
                       │
                       │   on cdk.tf.json line 94, in resource.aws_launch_template.ResumeParsingService-LTConstruct-test (ResumeParsingService-LTConstruct-test):
                       │   94:         "user_data": "${filebase64(\"$${path.module}/resumeparsingservice.sh\")}",
                       │     ├────────────────
                       │     │ while calling filebase64(path)
                       │
                       │ Invalid value for "path" parameter: no file exists at
                       │ "${path.module}/resumeparsingservice.sh"; 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 cloudformation following the terraform from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template ( typescript version)

the example have userData: Token.asString(Fn.filebase64("${path.module}/example.sh")), which didn't worked. i simplified and moved all the content to root directory and still it was not finding the scripts.

Versions

language : typescript

cdktf --version 0.20.9

node --version v20.16.0

Providers

No response

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

  • [ ] I'm interested in contributing a fix myself

Community Note

  • 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

rpatidar avatar Nov 05 '24 04:11 rpatidar