pulumi: Deserializing some resources in 2.14 is failing

As with #5705, I’m seeing these error messages when referring to one resource from another.

Unable to deserialize resource urn:pulumi:stack::project::myproj:aws:MyComponentResource$aws:iam/role:Role::myObjName, no module is registered for iam/role. and Unable to deserialize resource urn:pulumi:stack::project::aws:cloudwatch:EventRuleEventSubscription$aws:lambda/function:Function::myObjName, no module is registered for lambda/function.

And these exceptions are being thrown.

unhandled rejection: CONTEXT(35242): monitor.registerResource(resource:resource-id[aws:iam/rolePolicyAttachment:RolePolicyAttachment])-initial
STACK_TRACE:
Error
    at Object.debuggablePromise (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
    at runAsyncResourceOp (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:546:75)
    at Object.<anonymous> (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:169:9)
    at Generator.next (<anonymous>)
    at /pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
    at new Promise (<anonymous>)
    at __awaiter (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
    at /pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:132:63
unhandled rejection: CONTEXT(35260): monitor.registerResource(resource:ObjectUnderTest-RDSInstanceSchedule-start[aws:lambda/permission:Permission])-initial
STACK_TRACE:
Error
    at Object.debuggablePromise (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
    at runAsyncResourceOp (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:546:75)
    at Object.<anonymous> (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:169:9)
    at Generator.next (<anonymous>)
    at /pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
    at new Promise (<anonymous>)
    at __awaiter (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
    at /pulumi/projects/node_modules/@pulumi/pulumi/runtime/resource.js:132:63

The problem goes away when I downgrade Pulumi to 2.12.1 and Pulumi/AWS to 3.12.2. The Pulumi CLI is as 2.14.0 throughout.

Expected Behavior

RolePolicyAttachments should be able to refer to Roles via the role input. EventRuleSubscriptions should be able to refer to EventRules via the handler input.

Current Behavior

The above error messages are displayed and the tests abort with the above exception.

Steps to Reproduce

Refer to a Role from a RolePolicyAttachment:

    const role = new aws.iam.Role(name, {
      assumeRolePolicy: assumeRolePolicy.json
    });
    new aws.iam.RolePolicyAttachment(name, {
      role: role,
      policyArn: aws.iam.ManagedPolicy.AmazonSSMManagedInstanceCore
    });

It also happens when referring to an EventHandler from an EventHandlerSubscription.

    const handler = async (
      _: cloudwatch.EventRuleEvent,
    ) => {
      console.log("Stuff happens");
    };

    const subscription = new cloudwatch.EventRuleEventSubscription(name, rule, handler, {}, {});

Context (Environment)

It doesn’t happen during a pulumi preview or pulumi up. It does prevent Mocha tests from completing.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (9 by maintainers)

Most upvoted comments

I am also receiving this error. I am trying to create a Lambda permission:


    const sourceArn = all([region, accountId, api.id, lambda.name]).apply(
      (inputs) => {
        const [region, accountId, apiId, lambdaName] = inputs;
        return `arn:aws:execute-api:${region}:${accountId}:${apiId}/*/*/${lambdaName}`;
      }
    );

    const lambdaPermissionApi = new aws.lambda.Permission(
      'lambda-permission-api',
      {
        principal: 'apigateway.amazonaws.com',
        action: 'lambda:InvokeFunction',
        function: lambda,
        sourceArn: sourceArn,
      },
      { parent: this }
    );

But I get both types of error as everyone else. Oddly, I can preview the stack locally just fine with pulumi up, but I get the error on Github Actions where I am using the Pulumi GitHub action. I don’t know how to tell what version of Pulumi it uses (presumably the latest?) but I can see it uses pulumi-aws version 3.23.0.

I am getting very similar errors when running pulumi up, also only when I use function-type resources and only when I’m running it in the context of a large, typescript app (where the @pulumi dependencies are installed as dev depencencies), not when I try to reproduce in a separate repo.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

// Create a public HTTP endpoint (using AWS APIGateway)
const endpoint = new awsx.apigateway.API("hello", {
  routes: [
    // Serve static files from the `www` folder (using AWS S3)
    {
      path: "/",
      localPath: "www",
    },

    // Serve a simple REST API on `GET /name` (using AWS Lambda)
    {
      path: "/source",
      method: "GET",
      eventHandler: (req, ctx, cb) => {
        cb(undefined, {
          statusCode: 200,
          body: Buffer.from(JSON.stringify({ name: "AWS" }), "utf8").toString("base64"),
          isBase64Encoded: true,
          headers: { "content-type": "application/json" },
        });
      },
    },
  ],
});

// Export the public URL for the HTTP service
exports.url = endpoint.url;

This fails to run pulumi up:

❯ pulumi up
Previewing update (dev)

View Live: https://app.pulumi.com/dmiller/backend/dev/previews/1bbbd9a2-7ddd-4bc8-8140-92983fa3174d

     Type                                Name                                          Plan       Info
 +   pulumi:pulumi:Stack                 backend-dev                                   create     1 error; 48 messages
 +   └─ aws:apigateway:x:API             hello                                         create
 +      ├─ aws:iam:Role                  hello66382ec5                                 create
 +      ├─ aws:s3:Bucket                 hello                                         create
 +      ├─ aws:iam:Role                  hello4c238266                                 create
 +      ├─ aws:iam:Policy                hello66382ec5-LambdaFullAccess                create
 +      ├─ aws:iam:RolePolicyAttachment  hello4c238266                                 create
 +      ├─ aws:iam:RolePolicyAttachment  hello66382ec5-lambdaFullAccessCopyAttachment  create
 +      ├─ aws:apigateway:RestApi        hello                                         create
 +      ├─ aws:apigateway:Deployment     hello                                         create
 +      └─ aws:apigateway:Stage          hello                                         create

Diagnostics:
  pulumi:pulumi:Stack (backend-dev):
    error: Running program '/Users/dan/devel/backend/pulumi.ts' failed with an unhandled exception:
    TypeError: Cannot read property 'split' of undefined
        at deserializeProperty (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
        at Object.deserializeProperties (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
        at Generator.next (<anonymous>)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at resolveOutputs (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
        at Object.<anonymous> (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
        at Generator.throw (<anonymous>)

    TypeError: Cannot read property 'split' of undefined
        at deserializeProperty (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
        at Object.deserializeProperties (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
        at Generator.next (<anonymous>)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at resolveOutputs (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
        at Object.<anonymous> (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
        at Generator.throw (<anonymous>)
    TypeError: Cannot read property 'split' of undefined
        at deserializeProperty (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
        at Object.deserializeProperties (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
        at Generator.next (<anonymous>)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at resolveOutputs (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
        at Object.<anonymous> (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
        at Generator.throw (<anonymous>)

    unhandled rejection: CONTEXT(1440): monitor.registerResource(resource:hello-f61e7551[aws:lambda/permission:Permission])-initial
    STACK_TRACE:
    Error:
        at Object.debuggablePromise (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
        at runAsyncResourceOp (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:634:75)
        at Object.<anonymous> (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:257:9)
        at Generator.next (<anonymous>)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:219:63
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
    unhandled rejection: CONTEXT(1440): monitor.registerResource(resource:hello-f61e7551[aws:lambda/permission:Permission])-initial
    STACK_TRACE:
    Error:
        at Object.debuggablePromise (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
        at runAsyncResourceOp (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:634:75)
        at Object.<anonymous> (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:257:9)
        at Generator.next (<anonymous>)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at /Users/dan/devel/backend/node_modules/@pulumi/pulumi/runtime/resource.js:219:63
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)

This succeeds:

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

// Create a public HTTP endpoint (using AWS APIGateway)
const endpoint = new awsx.apigateway.API("hello", {
  routes: [
    // Serve static files from the `www` folder (using AWS S3)
    {
      path: "/",
      localPath: "www",
    },

    // Serve a simple REST API on `GET /name` (using AWS Lambda)
    // {
    //   path: "/source",
    //   method: "GET",
    //   eventHandler: (req, ctx, cb) => {
    //     cb(undefined, {
    //       statusCode: 200,
    //       body: Buffer.from(JSON.stringify({ name: "AWS" }), "utf8").toString("base64"),
    //       isBase64Encoded: true,
    //       headers: { "content-type": "application/json" },
    //     });
    //   },
    // },
  ],
});

// Export the public URL for the HTTP service
exports.url = endpoint.url;