sparse-intern-71089
01/12/2024, 4:09 PMfierce-terabyte-6114
01/12/2024, 4:14 PMApplyT
freezing-vase-18205
01/12/2024, 4:57 PMfreezing-vase-18205
01/12/2024, 4:59 PMpulumi.All()
but then I need to add every single output I am interested in in that functionfierce-terabyte-6114
01/12/2024, 5:01 PMAll
seems to be the only way to get multiple resourcesfierce-terabyte-6114
01/12/2024, 5:02 PMfreezing-vase-18205
01/12/2024, 5:05 PMsalmon-account-74572
01/12/2024, 5:55 PMfierce-terabyte-6114
01/12/2024, 5:56 PMfreezing-vase-18205
01/12/2024, 8:25 PMpulumi.All()
witchcraft made me switch right now to pulumi-Python.
As much as I am less proficient in Py than in Go, the inability to easily work with output native types made it hard to justify Go choicefreezing-vase-18205
01/13/2024, 11:19 PMpulumi stack output
doesfreezing-vase-18205
01/13/2024, 11:21 PMall
+ apply
to get “real” values from the outputs
For instance, the Py version is just a little bit better (since no type inference and can have named args):
# renderYAML waits for outputs to be ready
# and renders the kubeone_cluster to a YAML file
def renderYAML(cp_host, cp_int_ip, cp_hostname, static_workers):
def populate_spec(outputs):
kubeone_cluster["apiEndpoint"]["host"] = outputs["cp_host"]
kubeone_cluster["controlPlane"]["hosts"][0]["publicAddress"] = outputs[
"cp_host"
]
for worker_out in outputs["static_workers"]:
kubeone_cluster["staticWorkers"]["hosts"].append(
{
"publicAddress": worker_out[0],
"privateAddress": worker_out[0],
"sshUsername": "root",
"hostname": worker_out[1],
"bastion": outputs["cp_host"],
}
)
# writing kubeone yaml to file
with open("kubeone.yaml", "w") as f:
yaml.dump(
kubeone_cluster,
f,
sort_keys=False,
)
pulumi.Output.all(
cp_host=cp_host,
cp_int_ip=cp_int_ip,
cp_hostname=cp_hostname,
static_workers=static_workers,
).apply(populate_spec)