Scenario: I'm creating a SingleRunFargateTask dyna...
# general
a
Scenario: I'm creating a SingleRunFargateTask dynamic resource provider. I hoped to pass it's constructor a FargateTaskDefinition and then invoke run() on create, like so:
Copy code
const SingleRunFargateTaskProvider = {
  async create(inputs) {
    const id = crypto.randomBytes(16).toString("hex");
    const result = await inputs.fargateTaskDefn.run({
      cluster: inputs.ecsCluster
    });
    return { id };
  }
};
However I receive this Error:
Copy code
error: update failed

pulumi-nodejs:dynamic:Resource (repro-customfgtask):
    error: inputs.fargateTaskDefn.run is not a function
When I inspect the inputs, inputs.fargateTaskDefn is at that runtime, a string URN. Any guidance on how to make this work would be really appreciated! (My eventual use-case will be a database migration task that I tie to my RDS resource's lifetime). P.S/Sidenote: I am modelling this after the lambda/fargate example that captures a reference to a FargateTaskDefinition and uses the run() call at runtime (and I've tested that scenario/function serialization works fine. See: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/awsx/ecs/#task-definitions):
Copy code
const helloTask = new awsx.ecs.FargateTaskDefinition("hello-world", {
    container: {
        image: "hello-world",
        memory: 20,
    },
});

const api = new awsx.apigateway.API("examples-containers", {
    routes: [{
        path: "/run",
        method: "GET",
        eventHandler: async (req) => {
            const result = await helloTask.run({ cluster });
            return { statusCode: 200, body: "OK" };
        },
    }],
});
Is it because the
create
of a
dynamic.Provider
is a different execution context to the index.ts pulumi program on
pulumi up
? I could always programatically call
ecs.runTask()
using the aws-sdk in the
create
of the
dynamic.Provider
, but I just wonder if there's another way 🤔