https://pulumi.com logo
Title
r

rich-tiger-43483

02/17/2022, 2:57 PM
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:
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 👇
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

echoing-dinner-19531

02/17/2022, 4:21 PM
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

rich-tiger-43483

02/17/2022, 4:45 PM
Thanks for your reply, so is ok if I just do this with the
ID
?
group.id.apply(id => parseInt(id)
e

echoing-dinner-19531

02/17/2022, 4:51 PM
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

rich-tiger-43483

02/17/2022, 5:03 PM
Would be great, thank you!
e

echoing-dinner-19531

02/17/2022, 5:31 PM
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:
"oneOf": [
  {
    "type": "string"
  },
  {
    "type": "string",
    "$ref": "#/types/aws:s3/bucket:Bucket"
  }
],
r

rich-tiger-43483

02/18/2022, 2:55 AM
Ok, will dive more on this. Thanks again!