aws-toolkit-jetbrains icon indicating copy to clipboard operation
aws-toolkit-jetbrains copied to clipboard

Use custom tsconfig.json instead of aws-toolkit-tsconfig.json

Open sebastianroming opened this issue 3 years ago • 2 comments

Your Environment

  • OS: Windows 10
  • JetBrains product: WebStorm
  • JetBrains product version: 2021.2.3
  • AWS Toolkit version: 1.37-212
  • SAM CLI version: 1.37.0
  • JVM/Python version:

Question

I'm trying to create a new configuration for my Lambda. It works perfectley, except it creates it's custom tsconfig.json file, which causes the configuration run to break. image

If I compile manually (with my project-level tsconfig.json), and start the configuration again, it creates a custom directory aws-toolkit-ts-output, which doesn't exist (due to the previous error). Also, the lambda can't start locally, as the paths in my template.yaml are incorrect (pointing to the aws-toolkit-ts-output directory).

"C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd" local invoke --template C:\dev\aws\aws-lambda-service-requests\.aws-sam\build\template.yaml --event "C:\Users\srom01\AppData\Local\Temp\[Local] Test-event.json"
Invoking aws-toolkit-ts-output/src/handlers/service-request.serviceRequestsHandler (nodejs14.x)
Skip pulling image and use local one: public.ecr.aws/sam/emulation-nodejs14.x:rapid-1.37.0-x86_64.

Mounting C:\dev\aws\aws-lambda-service-requests\.aws-sam\build\Function as /var/task:ro,delegated inside runtime container
START RequestId: 2fcb8842-d473-4e07-afe4-1a8afa424fd5 Version: $LATEST
2022-02-21T14:57:30.275Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'service-request'\nRequire stack:\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","stack":["Runtime.ImportModuleError: Error: Cannot find module 'service-request'","Require stack:","- /var/runtime/UserFunction.js","- /var/runtime/index.js","    at _loadUserApp (/var/runtime/UserFunction.js:202:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)","    at internal/main/run_main_module.js:17:47"]}
21 Feb 2022 14:57:30,286 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 129 InvokeID=
2022-02-21T14:57:30.378Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'service-request'\nRequire stack:\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","stack":["Runtime.ImportModuleError: Error: Cannot find module 'service-request'","Require stack:","- /var/runtime/UserFunction.js","- /var/runtime/index.js","    at _loadUserApp (/var/runtime/UserFunction.js:202:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)","    at internal/main/run_main_module.js:17:47"]}
{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'service-request'\nRequire stack:\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","trace":["Runtime.ImportModuleError: Error: Cannot find module 'service-request'","Require stack:","- /var/runtime/UserFunction.js","- /var/runtime/index.js","    at _loadUserApp (/var/runtime/UserFunction.js:202:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)","    at internal/main/run_main_module.js:17:47"]}END RequestId: 980531e4-23de-43f2-8070-eaf8180cbcd2
REPORT RequestId: 980531e4-23de-43f2-8070-eaf8180cbcd2	Init Duration: 0.35 ms	Duration: 216.56 ms	Billed Duration: 217 ms	Memory Size: 128 MB	Max Memory Used: 128 MB	

Is there any way to use my project's tsconfig.json and the runner just use sam build with everything defined in template.yaml?

Thanks!

sebastianroming avatar Feb 21 '22 14:02 sebastianroming

Did you get an answer, or did you find a way around @sebastianroming ?

simara001 avatar Jun 11 '23 03:06 simara001

Also facing this issue, although with IntelliJ + TypeScript. We do not have our index.tf files at the top most level of the source folder but our tsconfig accounts for this (in fact we can deploy them as lambdas). Whenever I try to run my TS code via intellij the auto-generated script is used which of course does not consider my project structure.

Any support would be appreciated here.

nikimicallef avatar Nov 22 '23 13:11 nikimicallef