@pulumi/policy - v1.21.0
    Preparing search index...

    Function validateResourceOfType

    • A helper function that returns a strongly-typed resource validation function, used to check only resources of the specified resource class.

      For example:

      validateResource: validateResourceOfType(aws.s3.Bucket, (bucket, args, reportViolation) => {
      if (bucket.acl === "public-read" || bucket.acl === "public-read-write") {
      reportViolation("You cannot set public-read or public-read-write on an S3 bucket.");
      }
      }),

      Type Parameters

      • TResource extends Resource
      • TArgs

      Parameters

      • resourceClass: new (name: string, args: TArgs, ...rest: any[]) => TResource

        Used to filter this check to only resources of the specified resource class.

      • validate: TypedResourceValidation<Unwrap<NonNullable<TArgs>>>

        A callback function that validates if the resource definition violates a policy.

      Returns ResourceValidation