pulumi-kubernetes
pulumi-kubernetes copied to clipboard
Can't use .metadata.name output from a CustomResource when no metadata field is provided
Hello!
- Vote on this issue by adding a 👍 reaction
- To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)
Issue details
I'm creating a CustomResource without an explicit metadata.name, which pulumi fills in. But I am unable to then use .metadata.name as an input to other resources.
const githubPRBinding = new kubernetes.apiextensions.CustomResource(
`${name}-gh-pr-binding`,
{
apiVersion: "triggers.tekton.dev/v1beta1",
kind: "TriggerBinding",
spec: {
params: [
{ name: "git-revision", value: "$(body.pull_request.head.sha)" },
{ name: "git-url", value: "$(body.repository.clone_url)" },
{ name: "pr-merged", value: "false" },
],
},
},
{
parent: this,
}
);
const githubPRBindingName = githubPRBinding.metadata.name;
Produces an exception: TypeError: Cannot read properties of undefined (reading 'name').
This approach works on normally typed k8s resources.
As a workaround, specifying metadata: {} works.
The title of this ticket could also be written as the below to make the impact & circumstances more clear:
- Can't use .metadata.name output from a CustomResource
+ Can't use .metadata.name output from a CustomResource when there is no metadata arg