I'm using EventRuleEventSubscription to convert an...
# typescript
l
I'm using EventRuleEventSubscription to convert an inline fat-arrow function to an AWS lambda. Works nicely when I use the AWS SDK. When I try to use a little bit of Pulumi code (which I know I should be able to, there's an example in https://github.com/pulumi/examples/blob/master/aws-ts-scheduled-function/index.ts), I get an import error. Am I missing something? Maybe I need to import EC2 differently? The code that produces the error is simply
aws.ec2.getInstances({ filters: filters });
. The error is
Copy code
typescript
{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '@pulumi/aws/ec2/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/ec2/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:1133:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)",
        "    at Module.load (internal/modules/cjs/loader.js:977:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:877:14)",
        "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)",
        "    at internal/main/run_main_module.js:18:47"
    ]
}
The only relevant import in my Pulumi code is
import * as aws from "@pulumi/aws";
. Maybe I need to explicitly import EC2 somehow?
Added
import { getInstances } from "@pulumi/aws/ec2";
and changed the code to just be
getInstances({ filters: filters });
but that didn't change the result 😞
w
When I try to use a little bit of Pulumi code (which I know I should be able to, there's an example
Note that currently you cannot use the Pulumi SDKs "at runtime" inside a Lambda. The example you linked to uses the standard JavaScript AWS SDK. An instance of that SDK is available from
aws.sdk
for runtime code - so that code like this can work inside the Lambda:
Copy code
const s3Client = new aws.sdk.S3();
But this is still ultimately using the AWS SDK, not the Pulumi SDK.
l
Ah, that'll be it then. Ok I'll keep going with what I've got. 👍