rhythmic-rain-31941
09/29/2021, 11:37 PMrancher_ci_cluster = rancher2.Cluster()
chart = rancher2.AppV2("cluster-autoscaler",
cluster_id=rancher_ci_cluster.id,
namespace="kube-system",
repo_name=catalog.name.apply(lambda name: name),
chart_name="cluster-autoscaler",
chart_version="9.10.7",
values=f"""
awsRegion: {config.require("rancherAwsCiRegion")}
autoDiscovery:
clusterName: {rancher_ci_cluster.name.apply(lambda name: name)}
extraArgs:
balance-similar-node-groups: true
priorityClassName: system-cluster-critical
""",
opts=ResourceOptions(depends_on=catalog)
)
so in the above snippet i could read the rancher_ci_cluster.id without any apply() or all() . but for looking up name even though i used rancher_ci_cluster.name.apply(lambda name: name)
i still see it as an object instead of raw data <pulumi.output.Output object at 0x103a73e20>
. so can anyone help me understand what is that im missing here and how the behavior works?steep-toddler-94095
09/29/2021, 11:45 PMsomething.property.apply(lambda name: name)
is equivalent to something.property
. The lambda function is just the identity function so no transformation is performed.clusterName: rancher_ci_cluster.name
{}
but it looks like that property probably just wants a string
rhythmic-rain-31941
09/29/2021, 11:50 PMsteep-toddler-94095
09/29/2021, 11:50 PMinterpolate
function?Output<string>
doesn't workrhythmic-rain-31941
09/29/2021, 11:53 PMall()
and apply()
together?steep-toddler-94095
09/29/2021, 11:55 PMvalues=Output.all(config.require("rancherAwsCiRegion"), rancher_ci_cluster.name).apply(lambda s: f"""
awsRegion: {s[0]}
autoDiscovery:
clusterName: {s[1]}
extraArgs:
balance-similar-node-groups: true
priorityClassName: system-cluster-critical
""",
rhythmic-rain-31941
09/29/2021, 11:56 PMsteep-toddler-94095
09/30/2021, 12:03 AMrhythmic-rain-31941
09/30/2021, 12:04 AMconfig
(as this is pulumi.Config
) in Output
as its not a resourcesteep-toddler-94095
09/30/2021, 12:10 AMOutput.all
just takes Outputs. it doesn't need to be from a cloud resourcerhythmic-rain-31941
09/30/2021, 12:17 AMcatalog.name.apply(lambda name: name)
same as catalog.name
right, but catalog.name
was returning object, after using apply()
only it returned raw output, any thoughts on it? btw the catalog here is rancher2.CatalogV2
resourcesteep-toddler-94095
09/30/2021, 12:27 AMOutput<string>
is an object. It is not the same as a string
. So you can't use it in normal string interpolation. The reason why you got an object reference earlier is because you used it python's string interpolation, and the string value of an object is that string you got with the memory address.
What apply
does is it allows you to access the value wrapped by Output
. Within the callback function, you can treat an Output<string>
as a normal string. This allows you to use s[0]
and s[1]
in the code block above as regular strings.
catalog.name.apply(lambda name: name)
is the same as catalog.name
because the callback function you passed in is the identity function, not for any other reason.rhythmic-rain-31941
09/30/2021, 2:32 AM