This works: `this.clusterOidcProviderId = cluster....
# general
m
This works:
this.clusterOidcProviderId = cluster.core.oidcProvider?.id
l
If you run this before the provider is resolved, it will be
undefined
forever, won't it? It's resolved immediately.
You need to use
this.clusterOidcProviderId = cluster.core.oidcProvider.id
m
Thanks for the reply @little-cartoon-10569 - but since oidcProvider is an optional field for
new eks.Cluster({})
, Typescript is throwing an error. So I tried
const clusterOidcProvider = cluster.core.oidcProvider as any
and then
this.eksHash = clusterOidcProvider.id.apply((oidcProviderId: any) => oidcProviderId.split('/').slice(-1)[0])
but it’s still undefined.
Also, even if
oidcProvider
is optional, wouldn’t the apply run as a callback when the
oidcProvider
value is eventually resolved? If that’s the case,
this.eksHash
should resolve to the right value, no?
l
Then you're going to have to postpone getting the value until you know it is there. There is a problem in that you're using the same code to handle two different cases: one where the provider will never be there, and one where it will be there but isn't there yet.
The apply runs when the Output is resolved. But the code you have can run even if the variable doesn't have an Output, in which case, the id will be immediately undefined.
You could try
if (cluster.core.oidcProvider != undefined) { this.eksHash = this.clusterOidcProviderId?.apply(oidcProviderId => oidcProviderId.split('/').slice(-1)[0]); }