brave-glass-88708
06/21/2021, 11:59 PMimport * as k8s from "@pulumi/kubernetes";
import * as kx from "@pulumi/kubernetesx";
const serviceAccount = new k8s.core.v1.ServiceAccount("test-service-account");
serviceAccount.secrets.apply(secretName => {
console.log(secretName[0].name);
const token = k8s.core.v1.Secret.get(secretName[0].name,`${serviceAccount.metadata.namespace}/${secretName[0].name}`).data.apply(v => {
console.log(v['token']);
});
});
however, i am met with
error: preview failed
kubernetes:core/v1:Secret (test-service-account-gd83fdyj-token-f5wqw):
error: Preview failed: failed to read resource because of a failure to parse resource name from request ID: Calling [toString] on an [Output<T>] is not supported.
To get the value of an Output<T> as an Output<string> consider either:
1: o.apply(v => `prefix${v}suffix`)
2: pulumi.interpolate `prefix${v}suffix`
any suggestions?little-cartoon-10569
06/22/2021, 12:28 AMapply
on sectionName[0].name
, rather than secretName
.secretName
is 🙂steep-toddler-94095
06/22/2021, 2:06 AMinterpolate
to concat `Output<string>`s, but you don't need to use this if you use secretName.namespace
. And you can use array pattern matching to assign the first element to the variable secretName
import * as k8s from "@pulumi/kubernetes";
import * as kx from "@pulumi/kubernetesx";
const serviceAccount = new k8s.core.v1.ServiceAccount("test-service-account");
serviceAccount.secrets.apply(([secretName]) => {
console.log(secretName.name);
const token = k8s.core.v1.Secret.get(secretName.name, `${secretName.namespace}/${secretName.name}`).data.apply(v => {
console.log(v['token']);
});
});
brave-glass-88708
06/22/2021, 5:42 PM