Okay, I'm refining my previous issue with what I'v...
# general
a
Okay, I'm refining my previous issue with what I've learned. The problem seems to be when I reference the
task
in the Lamdba callback that I'm creating with
onSchedule
. So, this DOES work:
Copy code
const task = new awsx.ecs.FargateTaskDefinition(`task`, {
  container: {
    image: img,
    memoryReservation: 2048
  }
});

aws.cloudwatch.onSchedule(`task-schedule`, 'rate(5 minutes)',
  async (req) => {
    console.log('Is this thing on?')
    return { statusCode: 200, body: "OK" };
  }
);
But as soon as I reference the
task
in the callback, I get errors about missing modules. Even if I'm not trying to run the task:
Copy code
aws.cloudwatch.onSchedule(`task-schedule`, 'rate(5 minutes)',
  async (req) => {
    console.log(task); // just try to log the object -- don't even try to run it
    return { statusCode: 200, body: "OK" };
  }
);
This is the error that Lambda throws when it tries to run the callback:
Copy code
{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '@pulumi/awsx/ecs/index.js'\nRequire stack:\n- /var/task/__index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
    ...
}
So, it seems like is's an issue with how Pulumi is packaging the Lambda function, right? I'll add that the container image doesn't contain any references to Pulumi or dependencies, so the error probably isn't related to the image. I'm using the same image on other Fargate Services created by Pulumi, and it's running fine.