``` export interface CosmosContainerArgs { reg...
# typescript
s
Copy code
export interface CosmosContainerArgs {
    region: pulumi.Input<string>;
    endpoint: pulumi.Input<string>;
    masterKey: pulumi.Input<string>;
    client: any;
}

class MyResource extends pulumi.dynamic.Resource {
    constructor(name: string, props: MyResourceInputs, opts?: pulumi.CustomResourceOptions) {
        let region = args.region;
        let endpoint = args.endpoint;
        let masterKey = args.masterKey;

        let connectionPolicy = new cosmos.ConnectionPolicy();
        connectionPolicy.PreferredLocations = [args.region];

        const client = new cosmos.CosmosClient({
            endpoint,
            auth: { masterKey },
            connectionPolicy,
        });

        args.client = client;

        super(myprovider, name, props, opts); 
    }
}
Trying to initialise a custom client in the resource constructor, so the I can pass it on to the provider to work with. What is the best way to approach this? The above fails because
arg.region
returns
Promise
Copy code
Type 'Input<string>' is not assignable to type 'string'.
  Type 'Promise<string>' is not assignable to type 'string'.
w
You will most likely want to construct this client inside your CRUD implementations (or in a helper they call) using information passed in as arguments. When the data arrives at your CRUD implementations it will be raw `strings`s, not
Input<string>
.
s
but a
constructor
in the
ResourceProvider
that deals with all the CRUD implementations, will mess with the arguments that’s receiving from what I’ve noticed. How do you suggest doing it? Any example I can have a look at?
@tall-librarian-49374 this is what I’ve been trying to do. @white-balloon-205 has give it some thought, but it’s something I had already looked, with no initial success
t
I'm online now, let me have a look
One thing to keep in mind that the provider code will run at a different time and in a different process than the resource code. Therefore, I'm not actually sure that you can pass clients between them.
with two types of arguments (one with Outputs, other without) and passing them along
s
it was a very weird thing that I managed to resolve by clearing out a bit the state file… but definitely there was something in there cached