As I understand it, a CustomResource is used for resources created by normal providers. I think what you want is a dynamic provider, which will you can use to create "dynamic" Resources (which aren't any more dynamic than normal resources.. they're just created by dynamic providers 🙂 ). There's more detail here:
https://www.pulumi.com/docs/intro/concepts/resources/#dynamicproviders