Hi, I am creating my own provider using the TF bri...
# general
r
Hi, I am creating my own provider using the TF bridge and having some troubles with id types when linking resources using
ID
. I have a resource called
Group
and other called
Check
. You should be able to use the
groupId
property of the
Check
in order to link them. The problem is when I tried to do it, I get this error message:
Copy code
error: checkly:index/check:Check resource 'pulumi-api-check' has a problem: Attribute must be a whole number, got 257503. Examine values at 'Check.GroupId'
I guess this is related with types and for some reason the
ID
of the group is being returned as
string
when it should be a
number
. In my TF provider the
ID
has the correct type, so I am not sure why this is happening. I could try to manually parse the
ID
to integer when setting it in the group but don’t think will be a good DX. Here is the JS source of the example I am trying to make it work 👇
Copy code
const checkly = require( "@pulumi/checkly");

const group = new checkly.CheckGroup("group", {
  activated: true,
  concurrency: 1,
  locations: ['us-east-1'],
});

new checkly.Check("api-check", {
  activated: true,
  frequency: 10,
  type: "API",
  groupId: group.id
});
Any help/suggestion will be appreciated 🙏
e
The engine always passes resource IDs around as strings currently. If you know it should be a number you can parse that in the resource provider. I don't think there's anyway to generate SDK code where the ID is a different type.
r
Thanks for your reply, so is ok if I just do this with the
ID
?
Copy code
group.id.apply(id => parseInt(id)
e
Yes. I think some resource also allow taking the
Group
object and auto-resolving to it's id instead of taking a plain id value. I'll see if I can dig out an example.
r
Would be great, thank you!
e
So if you look at BucketObjects in TypeScript it's bucket input can be a string or a Bucket object. Looks like this is done by just having the input property schema set to:
Copy code
"oneOf": [
  {
    "type": "string"
  },
  {
    "type": "string",
    "$ref": "#/types/aws:s3/bucket:Bucket"
  }
],
r
Ok, will dive more on this. Thanks again!