title: Deploy lambda function on aws-pulumi
body: <p>I'm trying to deploy a lambda Function on my AWS account, that zips a file that is uploaded into &quot;lambda-bucket-in&quot; onto a bucket &quot;lambda-bucket-out&quot;. The example I'm trying to follow is <a href="https://www.pulumi.com/blog/easy-serverless-apps-and-infrastructure-real-events-real-code/" rel="noreferrer">this</a> one, specifically the <strong>second</strong> way (the first does its job properly).</p>
  <p>My pulumi code is the following one:</p>
  <pre><code>import * as aws from &quot;@pulumi/aws&quot;;
  import * as pulumi from &quot;@pulumi/pulumi&quot;;
  
  
  const tpsReports = new aws.s3.Bucket(&quot;lambda-bucket-in&quot;);
  const tpsZips = new aws.s3.Bucket(&quot;lambda-bucket-out&quot;);
  
  
  // First, create some IAM machinery:
  const zipFuncRole = new aws.iam.Role(&quot;zipTpsReportsFuncRole&quot;, {
      assumeRolePolicy: {
         Version: &quot;2012-10-17&quot;,
         Statement: [{
            Action: &quot;sts:AssumeRole&quot;,
            Principal: {
               Service: &quot;lambda.amazonaws.com&quot;,
            },
            Effect: &quot;Allow&quot;,
            Sid: &quot;&quot;,
         }],
      },
   });
   new aws.iam.RolePolicyAttachment(&quot;zipTpsReportsFuncRoleAttach&quot;, {
      role: zipFuncRole,
      policyArn: aws.iam.ManagedPolicy.AWSLambdaExecute,
   });
   
   // Next, create the Lambda function itself:
   const zipFunc = new aws.lambda.Function(&quot;zipTpsReportsFunc&quot;, {
      environment: {
         variables: {
            &quot;TPS_ZIP_BUCKET&quot;: tpsZips.bucket,
         },
      },
      code: new pulumi.asset.AssetArchive({
         &quot;.&quot;: new pulumi.asset.FileArchive(&quot;app&quot;),
      }),
      runtime: &quot;nodejs12.x&quot;,
      role: zipFuncRole.arn,
   });
   
   // Finally, register the Lambda to fire when a new TPS report arrives:
   tpsReports.onObjectCreated(&quot;zipTpsReports&quot;, zipFunc);
  </code></pre>
  <p>While &quot;app&quot; file, with the lambda function is:</p>
  <pre><code>   const AdmZip = require(&quot;adm-zip&quot;);
     const s3 = new aws.sdk.S3();
     for (const rec of e.Records || []) {
        const zip = new AdmZip();
        const [ buck, key ] = [ rec.s3.bucket.name, rec.s3.object.key ];
        console.log(`Zipping ${buck}/${key} into ${tpsZips.bucket.get()}/${key}.zip`);
        const data = await s3.getObject({ Bucket: buck, Key: key }).promise);
        zip.addFile(key, data.Body);
        await s3.putObject({
           Bucket: tpsZips.bucket.get(),
           Key: `${key}.zip`,
           Body: zip.toBuffer(),
        }).promise();
     }
  </code></pre>
  <p>While running pulumi with the command <code>pulumi up --yes</code>, and after inserting the password, it returns:</p>
  <pre><code>Previewing update (my-lambda):
       Type                                  Name                         Plan       Info
   +   pulumi:pulumi:Stack                   bucket-my-lambda-my-lambda   create     1 error; 48 messages
   +   ├─ aws:s3:Bucket                      lambda-bucket-out            create     
   +   ├─ aws:s3:Bucket                      lambda-bucket-in             create     
   +   │  ├─ aws:s3:BucketEventSubscription  zipTpsReports                create     
   +   │  └─ aws:s3:BucketNotification       zipTpsReports                create     
   +   ├─ aws:iam:Role                       zipTpsReportsFuncRole        create     
   +   └─ aws:iam:RolePolicyAttachment       zipTpsReportsFuncRoleAttach  create     
   
  Diagnostics:
    pulumi:pulumi:Stack (bucket-my-lambda-my-lambda):
      TypeError: Cannot read property 'split' of undefined
          at deserializeProperty (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
          at Object.deserializeProperties (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
          at Generator.next (&lt;anonymous&gt;)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
          at new Promise (&lt;anonymous&gt;)
          at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
          at resolveOutputs (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
          at Object.&lt;anonymous&gt; (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
          at Generator.throw (&lt;anonymous&gt;)
      TypeError: Cannot read property 'split' of undefined
          at deserializeProperty (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
          at Object.deserializeProperties (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
          at Generator.next (&lt;anonymous&gt;)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
          at new Promise (&lt;anonymous&gt;)
          at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
          at resolveOutputs (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
          at Object.&lt;anonymous&gt; (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
          at Generator.throw (&lt;anonymous&gt;)
   
      unhandled rejection: CONTEXT(1251): monitor.registerResource(resource:zipTpsReports[aws:lambda/permission:Permission])-initial
      STACK_TRACE:
      Error:
          at Object.debuggablePromise (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
          at runAsyncResourceOp (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:634:75)
          at Object.&lt;anonymous&gt; (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:257:9)
          at Generator.next (&lt;anonymous&gt;)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
          at new Promise (&lt;anonymous&gt;)
          at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:219:63
          at runMicrotasks (&lt;anonymous&gt;)
          at processTicksAndRejections (internal/process/task_queues.js:93:5)
      unhandled rejection: CONTEXT(1251): monitor.registerResource(resource:zipTpsReports[aws:lambda/permission:Permission])-initial
      STACK_TRACE:
      Error:
          at Object.debuggablePromise (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
          at runAsyncResourceOp (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:634:75)
          at Object.&lt;anonymous&gt; (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:257:9)
          at Generator.next (&lt;anonymous&gt;)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
          at new Promise (&lt;anonymous&gt;)
          at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:219:63
          at runMicrotasks (&lt;anonymous&gt;)
          at processTicksAndRejections (internal/process/task_queues.js:93:5)
   
      error: Running program '/home/andrea/Piratech/pulumi/bucket-my-lambda' failed with an unhandled exception:
      TypeError: Cannot read property 'split' of undefined
          at deserializeProperty (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
          at Object.deserializeProperties (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
          at Generator.next (&lt;anonymous&gt;)
          at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
          at new Promise (&lt;anonymous&gt;)
          at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
          at resolveOutputs (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
          at Object.&lt;anonymous&gt; (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
          at Generator.throw (&lt;anonymous&gt;)
  </code></pre>
  <p>Does anyone know how to fix this issue, and what does it stand for?
  Thank you for your help.</p>