Meanwhile, how can I convert the `id: Output<st...
# general
l
Meanwhile, how can I convert the
id: Output<string>
of my parent group to an
number | Promise<number> | OutputInstance<number>
which I can use as input for the
parentId
of my child group?
a
Something like this should work for the conversion:
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";

const group1 = new gitlab.Group("group1", {
    path: "path1",
});

// Convert Output<string> to Output<number>
const parentIdNum = group1.id.apply(string => parseInt(string));

const group2 = new gitlab.Group("group2", {
    path: "path2",
    parentId: parentIdNum
});
If you expect to be doing this a lot, you could also wrap the apply bit as a function like so:
Copy code
// Usage: stringToNumber(group.id)
function stringToNumber(stringOut: pulumi.Output<string>): pulumi.Output<number>{
    return stringOut.apply(string => parseInt(string));
}
That way you don't have to repeat the apply part every time.
l
I also filed this as an issue: https://github.com/pulumi/pulumi-gitlab/issues/28 The answer there is probably the shortest possible:
parentId: something.id.apply(id => +id)
👍 1