hi, trying to use AWSX package with 4.24.1, is tha...
# general
b
hi, trying to use AWSX package with 4.24.1, is that still valid? I'm getting an error telling me that there is no local package.json in the project, but for all other of my resources I have a package.json further up my directory tree and it seems only AWSX doesn't like that configuration. I have all my node_modules and package.json in the
/data/pulumi
directory built into my container:
Copy code
error: Error: Error reading file '/data/pulumi/infra/aws/projects/sitebuilder/environment/apigateway/package.json' when computing package dependencies. Error: ENOENT: no such file or directory, open '/data/pulumi/infra/aws/projects/sitebuilder/environment/apigateway/package.json'
        at readFile (/data/pulumi/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:167:19)
        at computeDependenciesDirectlyFromPackageFile (/data/pulumi/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:150:22)
        at /data/pulumi/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:115:36
        at /data/pulumi/node_modules/read-package-tree/rpt.js:162:20
you can see it's erroring at
at /data/pulumi/node_modules/read-package-tree/rpt.js:162:20
so it does seem to be finding/running the pulumi code from further up
creating a symlink to the package.json further up in the local directory seems to be working but i'm getting all kinds of warnings about dependencies
l
Is this happening when serializing functions for lambda Azure functions or similar? There's a.. feature deficiency?... in that area. It should work in all projects that have no function serialization, I think.
b
no, i was just trying to use AWSX most basic example for apigateway
was a standalone index.ts file in a folder, normal setup just doing a
pulumi up
on it
Copy code
import * as awsx from "@pulumi/awsx";

// Define a new GET endpoint that just returns a 200 and "hello" in the body.
const api = new awsx.apigateway.API("example", {
    routes: [{
        path: "/",
        method: "GET",
        eventHandler: async (event) => {
            // This code runs in an AWS Lambda anytime `/` is hit.
            return {
                statusCode: 200,
                body: "Hello, API Gateway!",
            };
        },
    }],
})
basically just this ^ i needed a simple public endpoint, but then i see it doesn't handle CORS so I just went back and used some other code I had with all the OPTIONS/MOCK stuff in it
l
Yes, so there's function serialization there.
The eventHandler is bundled up during the Pulumi
up
in order to be sent to AWS.
There is a known issue with this. Pulumi assumes that the current directory is the one with package.json, node_modules, etc.
So if that code isn't in your top-level directory, you need symlinks to make it work, for now.
b
ok thanks for reply, for now i'm past it, but good to know