nice-hamburger-52192
03/02/2020, 5:23 AM... (other code omitted) ...
bucket.onObjectCreated('on_created', async e => {
if (e.Records) {
for (const rec of e.Records) {
const file = aws.s3.getBucketObject({
bucket: bucketName.get(),
key: rec.s3.object.key
});
console.log('body', (await file).body);
}
}
});
I get this error message in CloudWatch:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module '@pulumi/aws/s3/index.js'\nRequire stack:\n- /var/task/__index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module '@pulumi/aws/s3/index.js'",
"Require stack:",
"- /var/task/__index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:955:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)",
" at Module.load (internal/modules/cjs/loader.js:811:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:723:14)",
" at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)",
" at internal/main/run_main_module.js:17:11"
]
}
This is the line that is causing the issue:
const file = aws.s3.getBucketObject({
I have this import at the top of my TypeScript file:
import * as aws from '@pulumi/aws';
So what am I doing wrong?white-balloon-205
03/02/2020, 6:05 AMaws.sdk
.
See for example: https://github.com/pulumi/examples/blob/11d7bb90bf5b7b2df7fb59c6fe48cca971faefc5/aws-ts-scheduled-function/index.ts#L14nice-hamburger-52192
03/02/2020, 1:06 PM