polite-napkin-90098
07/20/2022, 9:13 PMexport const publicSubnetIds = cluster.core.publicSubnetIds;
and then import them into another stack with
const pubsub = stackMon.getOutput("publicSubnetIds");
I then need to use them to annotate an ingress in a helm chart something like
ingress: {
annotations: {
'<http://alb.ingress.kubernetes.io/subnets|alb.ingress.kubernetes.io/subnets>': `${pubsub[0]}, ${pubsub[1]}`
or
'<http://alb.ingress.kubernetes.io/subnets|alb.ingress.kubernetes.io/subnets>': `${pubsub.join(',')}`
but this results in
Property 'join' does not exist on type 'OutputInstance<any>'.
or a similar error saying I can't index an Output<any> with 0 or 1
What am I getting wrong here? Can I not export an array?
Do I need some apply magic on the gotten output before Typescript will accept it is and array and can be joined?rich-cat-16319
07/21/2022, 2:06 AMgetOutput
returns an object of type Output
getOutputValue
instead or do pubsub.apply(value => { // your code that uses the value[0] here })
polite-napkin-90098
07/21/2022, 3:29 PMconst pubsub = stackMon.getOutput("publicSubnetIds");
const grafana = pulumi.all(pubsub).apply(([subnet1, subnet2])=> {
return new k8s.helm.v3.Release("grafana", {
...
values: {
...
ingress: {
...
annotations: {
...
'<http://alb.ingress.kubernetes.io/subnets|alb.ingress.kubernetes.io/subnets>': `${subnet1}, ${subnet2}`,
},
},
I've removed some static config lines to make it clearer.
Now pubsub is an Output<any> which contains and array of 2 strings, or will contain that at runtime when it's looked up.
and when I try and run this I get
index.ts(132,28): error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'Output<any>' is not assignable to parameter of type 'unknown[]'.
Type 'OutputInstance<any>' is missing the following properties from type 'unknown[]': length, pop, push, concat, and 29 more.
index.ts(132,44): error TS7031: Binding element 'subnet1' implicitly has an 'any' type.
index.ts(132,53): error TS7031: Binding element 'subnet2' implicitly has an 'any' type.
any ideas?const publicSubnetIds = pubsub.apply(list => list.join(','));
Calling [toString] on an [Output<T>] is not supported.
const pubsub = stackMon.getOutput("publicSubnetIds");
...
const pubsubId = pubsub.apply((l: Array<string>) => {
return l.map(a => `${a}`).join(",");
});
const grafana = new k8s.helm.v3.Release("grafana", {
...
values: {
ingress: {
annotations: {
'<http://alb.ingress.kubernetes.io/subnets|alb.ingress.kubernetes.io/subnets>': pulumi.interpolate `${pubsubId}`,
Is what actually manages to get the annotation to work :D