I have created a pulumi.dynamic.Resource that uses...
# typescript
e
I have created a pulumi.dynamic.Resource that uses the check method to check if its the 1st time the provider has run through a life cycle by checking if there are any values in the olds parameter. It then passes a firstRun=true param as one of the inputs to the create method which takes action accordingly. For some reason the check method is being called twice, 1st time it has old and new values, 2nd time its called with only new values then the create method is being invoked which then has no idea if its the first time. My project only has one instance of this resource. Any thoughts? Snippet:
Copy code
export class CloudfrontInvalidationResource extends pulumi.dynamic.Resource implements CloudfrontInvalidationResourceOutputs {
  public readonly cfDistributionId!: Output<ID>;
  public readonly invalidationId!: Output<string>;
  public readonly invalidationPaths!: Output<string[]>;
  public readonly buildHash!: pulumi.Output<string>;
  public readonly firstRun!: pulumi.Output<boolean>;

  constructor(name: string, props: CloudfrontInvalidationResourceInputs, opts?: pulumi.CustomResourceOptions) {
    const cfInvalidationProvider: pulumi.dynamic.ResourceProvider = {
      check: async (olds: CloudfrontInvalidationResourceInputs, news: CloudfrontInvalidationResourceInputs): Promise<CheckResult> => {
        console.log('******* check ' + name, {oldFirstRun: olds.firstRun, newFirstRun: news.firstRun, oldBuildHash: olds.buildHash, newBuildHash: news.buildHash});
        const firstRun = !olds.buildHash;
        return {
          inputs: { ...news, firstRun }
        };
      },
Looks like the method invocation order is check(with old and new), diff, check(missing old values), create