freezing-umbrella-80278
01/06/2022, 1:32 PMimport * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const foo = new digitalocean.KubernetesCluster("foo", {
region: "nyc1",
version: "1.20.2-do.0",
nodePool: {
name: "front-end-pool",
size: "s-2vcpu-2gb",
nodeCount: 3,
},
});
Example code taken from the Pulumi DigitalOcean package documentation.
How do I retrieve the droplet node IPv4 addresses for use in say creating DnsRecord
resources?
const _default = new digitalocean.Domain("default", {name: "<http://example.com|example.com>"});
// This code doesn't work because foo.nodePool is just the inputs.
const dnsRecords = foo.nodePool.nodes(node => new digitalocean.DnsRecord("www", {
domain: _default.name,
type: "A",
value: node.ipv4Address,
}));
I assume I have to either use the async methods such as
https://www.pulumi.com/registry/packages/digitalocean/api-docs/getkubernetescluster/
function getKubernetesCluster(args: GetKubernetesClusterArgs, opts?: InvokeOptions): Promise<GetKubernetesClusterResult>
But the problem then is I can't pass the cluster ID to this method as the resource has not bee provisioned yet when this method is called.
I also thought of generating a resource using the static get
method defined on the resource but I also don't think I have the ID of the cluster to call this method yet.
https://www.pulumi.com/registry/packages/digitalocean/api-docs/kubernetescluster/#look-up
public static get(name: string, id: Input<ID>, state?: KubernetesClusterState, opts?: CustomResourceOptions): KubernetesCluster
prehistoric-activity-61023
01/06/2022, 4:43 PMbillowy-army-68599
freezing-umbrella-80278
01/06/2022, 4:56 PMprehistoric-activity-61023
01/06/2022, 4:57 PMfreezing-umbrella-80278
01/06/2022, 4:59 PMdigitalocean.getDropletOutput
return a promise and therefore need to be awaited?prehistoric-activity-61023
01/06/2022, 5:02 PMfreezing-umbrella-80278
01/06/2022, 5:03 PMprehistoric-activity-61023
01/06/2022, 5:04 PMfreezing-umbrella-80278
01/06/2022, 5:05 PMprehistoric-activity-61023
01/06/2022, 5:05 PMfreezing-umbrella-80278
01/06/2022, 5:06 PMprehistoric-activity-61023
01/06/2022, 5:07 PMfreezing-umbrella-80278
01/06/2022, 5:08 PMbillowy-army-68599
doesn't digitalocean.getDropletOutput return a promise and therefore need to be awaited?Only if you're doing some string manipulation, if you're passing the result to another resource, Pulumi will figure it out for you
freezing-umbrella-80278
01/06/2022, 5:16 PMn
is actually a pending promise and you're attempting to access n.ipv4Address
when constructing the DnsRecord
.
So the graph is created and then Pulumi will ensure the previous dependency and it's outputs are available before resolving the DnsRecord
?billowy-army-68599
apply()
is like saying "wait for this thing to resolve"
getSomethingOutput
is similarfreezing-umbrella-80278
01/06/2022, 5:19 PMbillowy-army-68599