Resource methods
Provider SDKs may also include methods attached to a resource type. These methods return computed values from resources you are managing with Pulumi. For example, in the EKS SDK, the Cluster resource has a .GetKubeconfig method:
getKubeconfig(args?: Cluster.GetKubeconfigArgs): Output<Cluster.GetKubeconfigResult>
public Output<string> GetKubeconfig(ClusterGetKubeconfigArgs? args = null)
func (r *Cluster) GetKubeconfig(ctx *pulumi.Context, args *ClusterGetKubeconfigArgs) (pulumi.StringOutput, error)
def get_kubeconfig(self,
profile_name: Optional[pulumi.Input[str]] = None,
role_arn: Optional[pulumi.Input[str]] = None) -> Output[str]:
...
No example available for Java
No example available for YAML
Pulumi HCL has no method syntax. A call block invokes the method instead, labeled with the resource’s logical name and the method name in snake_case, and its results are read as call.<resource>.<method>.<attribute>. The required_providers entry is required: without source = "pulumi/eks", an unqualified eks resolves against the OpenTofu registry rather than the native Pulumi EKS package that defines this method.
terraform {
required_providers {
eks = {
source = "pulumi/eks"
}
}
}
resource "eks_cluster" "cluster" {
# ...
}
call "cluster" "get_kubeconfig" {
profile_name = "my-profile"
}
output "kubeconfig" {
value = call.cluster.get_kubeconfig.result
sensitive = true
}
Unlike provider functions, methods always appear in the output form: they take Input arguments, and return an Output (because they cannot execute until after the resource has been created). Resource methods do not accept invoke options.