i’m attempting to create some AWS lambdas with pul...
# typescript
b
i’m attempting to create some AWS lambdas with pulumi however I’m having some trouble. my pulumi project is configured so the source code is in
src/
rather than in the top level dir. my function definition looks like this:
Copy code
const myFunction = new aws.serverless.Function("my-func", {
    callback: (a, b, c) => { console.log(a,b,c); }
});
but when i run
pulumi up
i get the following error:
Copy code
Error reading file '<path-to-project>/src/package.json' when computing package dependencies. Error: ENOENT: no such file or directory, open '<path-to-project>/src/package.json'
is there a way I can get pulumi to look up a directory? or is there a way i can define a function inline without it having to check the package.json?
s
@breezy-butcher-78604 Why not simply running
pulumi up
in
src/
working-directory?
b
because the
Pulumi.yaml
file is not in that directory
my dir structure is as follows:
Copy code
src/
  index.ts
config/
  Pulumi.dev.yaml
  Pulumi.prod.yaml
Pulumi.yaml
package.json
package-lock.json
s
Aha. Do you have set
"main": "src/index"
in the
package.json
? No
tsconfig.json
?
b
i don’t have
main
set in package.json, and I do have a
tsconfig.json
file but chose to omit it from the above for simplicity
pulumi itself functions fine, i can create resources fine, this appears to be a problem with the function serialisation functionality requiring a package.json to be in the same dir as the template code
s
Ah, I see. So, then I can’t help you on this. Sorry. Best you check in the code in
pulumi-aws
.
g
You can specify the entrypoint in your
Pulumi.yaml
in a similar manner to package.json:
Copy code
main: src/
I believe that should do it.
b
i’ve already got that in my
Pulumi.yaml
file, the problem isn’t that pulumi cant find the index.ts, its that when it goes to create the
myFunc
resource, it needs to serialise the code in
callback
. I assume part of that process involves reading a
package.json
file to figure out what dependencies to package with it.
since there’s no
package.json
file in
src
(since there are no dependencies) it seems to fail.
g
Gotcha. I was thinking setting that in
Pulumi.yaml
would help. Can you open an isssue at https://github.com/pulumi/pulumi-aws with code to reproduce it?
b
sure thing
f
@breezy-butcher-78604 I replied to the issue with a modification for what I think you’re trying to accomplish
If that’s not quite right, let me know
b
that seems to work, but it now means any paths i use in the template are now relative to the top-level dir. not a huge issue though
thanks Lee
👍 1