sparse-intern-71089
04/06/2022, 3:19 PMpolite-napkin-90098
04/06/2022, 3:31 PM// because the node sg is wrapped up in some weird output nonsense we need to free it
nsg := cluster.NodeSecurityGroup.ApplyT(func(nodesg *ec2.SecurityGroup) pulumi.StringOutput {
return nodesg.ID().ToStringOutput()
}).ApplyT(func(id interface{}) string {
return id.(string)
}).(pulumi.StringOutput)
cluster
is an EKS cluster created using eks.NewCluster
what I think this code does is create a function called nodesg which takes a *ec2.SecurityGroup object as input and returns a pulumi.StringOutput object.
That function returns the output of the ID() function fed into the ToStringOutput() function both of which are provided in the nodesg *ec2.SecurityGroup object which we were taking as an input.
But then that seems to be nested with a second ApplyT which declares a function called id which takes an interface{} and returns a string, which I guess is taking the output of the nodesg function (which I thought was a pulumi.StringOutput, but I guess it's also an interface{}) and converting it to a string, which is then converted back to a pulumi.StringOutput but the last .()
Am I right? Am I close? I'd appreciate any insight into what this code does as I really don't think I understand it.polite-napkin-90098
04/06/2022, 3:37 PM// extract the role from the cluster output
iRole := cluster.Core.ApplyT(func(irole *eks.CoreData) pulumi.StringOutput {
return irole.InstanceRoles[0].Name
})
I've tried this, I've tried adding a second .ApplyT with the func(foo interface{}) string {... and I've tried having .(pulumi.StringOuput) after the last )polite-napkin-90098
04/06/2022, 3:40 PMDiagnostics:
pulumi:pulumi:Stack (EKS-EKS-test):
panic: applier must have 1 input parameter assignable from eks.CoreData
goroutine 1 [running]:
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.makeContextful({0x1110880|github.com/pulumi/pulumi/sdk/v3/go/pulumi.makeContextful({0x1110880>, 0x14d7718}, {0x164b750, 0x145f9e0})
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/types.go:340 +0x4a6
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*OutputState).ApplyT(0xc0000d7490|github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*OutputState).ApplyT(0xc0000d7490>, {0x1110880, 0x14d7718})
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/types.go:419 +0x5d
main.main.func1(0xc00037db80)
/home/ubuntu/docker/EKS/pulumi/main.go:411 +0x32b3
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunWithContext|github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunWithContext>(0xc00037db80, 0x14d7720)
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:103 +0x199
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunErr(0x43efc5|github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunErr(0x43efc5>, {0x0, 0x0, 0xc0000001a0})
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:84 +0x310
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.Run(0x0|github.com/pulumi/pulumi/sdk/v3/go/pulumi.Run(0x0>, {0x0, 0x10d0680, 0xc0000001a0})
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:41 +0x25
main.main()
/home/ubuntu/docker/EKS/pulumi/main.go:18 +0x27
exit status 2
error: an unhandled error occurred: program exited with non-zero exit code: 1
Which I must confess confuses me further, but maybe it wants me to have one of the Input parameters used in my function, which I'll try next.polite-napkin-90098
04/06/2022, 3:40 PMlimited-rainbow-51650
04/06/2022, 3:59 PM// because the node sg is wrapped up in some weird output nonsense we need to free it
Question: do you expect to get a (free) string
after using ApplyT
callback which you would be able to use further in your application?
The reason I’m asking this is that I have been bitten by this myself when I started using Pulumi. In an oversimplified way, you have to think as the language host (the runtime you use to write your infra code in, in your case Go) running your infra code, which talks to the Pulumi engine to instruct which resources need to be set up. By the time your code has run, none of your resources have been set up yet. The Pulumi engine takes the instructions, calculates a directed acyclic graph (DAG) and knows in which order it can set up these resources based on outputs of one resource being used as input to others. Think of an output as a bucket which will have a value in the future. ApplyT
will invoke your call-back function at the time the value becomes available, but the result you return in your callback function, will be put again in an Output which you can pass around as inputs further in your code.polite-napkin-90098
04/06/2022, 4:04 PMlimited-rainbow-51650
04/06/2022, 4:12 PMnsg := cluster.NodeSecurityGroup.ApplyT(...
Where do you get NodeSecurityGroup
from? I can’t find this as an output in the API docs of `Cluster`:
• aws-classic: https://www.pulumi.com/registry/packages/aws/api-docs/eks/cluster/#outputs
• aws-native: https://www.pulumi.com/registry/packages/aws-native/api-docs/eks/cluster/#outputspolite-napkin-90098
04/06/2022, 4:19 PMbored-oyster-3147
04/06/2022, 4:30 PMpulumi.CustomResourceState
while the CoreDataOutput type inherits from pulumi.OutputState
. Maybe I'm misunderstanding but given that eks
is one of the combined providers, is one of those properties actually a Resource being forwarded from the inner component while the other is an Output?bored-oyster-3147
04/06/2022, 4:33 PMpolite-napkin-90098
04/06/2022, 4:36 PMbored-oyster-3147
04/06/2022, 4:36 PMbored-oyster-3147
04/06/2022, 4:43 PMApplyT
delegate returns a stringOutput
? Shouldn't your delegate return a non-output type, since the ApplyT
method signature is essentially Output<Y> Apply<T>(Func<T, Y> delegate);
. I think your first working example has some excessive ApplyT
callspolite-napkin-90098
04/06/2022, 4:46 PMirole.InstanceRoles[0].Name
seems to be a pulumi.StringOutput, although I could always change that.bored-oyster-3147
04/06/2022, 4:47 PMstring
into a stringOutput
2. Your second apply turns in back into a string
3. You turn the result back into a stringOutput
Kinda confused by that snippetlimited-rainbow-51650
04/06/2022, 4:49 PMbored-oyster-3147
04/06/2022, 4:51 PMpolite-napkin-90098
04/06/2022, 4:51 PMkubeconfig := cluster.Kubeconfig.ApplyT(func(kc interface{}) string {
str, err :=json.Marshal(kc)
if err != nil {
panic(err)
}
return string(str)
}).(pulumi.StringOutput)
I guess that's more straight forward with the ApplyT taking the interface kc and returning a string made by marshalling the jsonbored-oyster-3147
04/06/2022, 4:51 PMpolite-napkin-90098
04/06/2022, 4:53 PMpanic: applier must have 1 input parameter assignable from eks.CoreData
errorlimited-rainbow-51650
04/06/2022, 4:54 PMnsg := cluster.NodeSecurityGroup.ApplyT(func(nodesg *ec2.SecurityGroup) pulumi.StringOutput {
return nodesg.ID()
}).(pulumi.StringOutput)
In my head, I would simplify the first example to this. Don’t know if this is valid Go+Pulumi code though.bored-oyster-3147
04/06/2022, 4:54 PM// extract the role from the cluster output
iRole := cluster.Core.InstanceRoles.ApplyT(func(irole *whateverthistypeis) string {
return irole[0].Name
}).(pulumi.StringOutput)
Or do the typings not permit you to access InstanceRoles
without the apply? Again this is me having trouble reading golang type definitions lolpolite-napkin-90098
04/06/2022, 4:54 PMpolite-napkin-90098
04/06/2022, 4:55 PMbored-oyster-3147
04/06/2022, 4:56 PMCore has no function or property InstanceRoles
if Core
was an outputpolite-napkin-90098
04/06/2022, 4:59 PM/main.go:350:16: cannot use sg.CustomResourceState.ID() (type pulumi.IDOutput) as type pulumi.StringOutput in return argument
so I think the second ApplyT is turning the pulumi.IDOutput into a pulumi.StringOutputbored-oyster-3147
04/06/2022, 5:00 PMlimited-rainbow-51650
04/06/2022, 5:01 PMpolite-napkin-90098
04/06/2022, 5:02 PM// because the cluster sg is wrapped up in some weird output nonsense we need to free it
sgid := cluster.NodeSecurityGroup.ApplyT(func(sg *ec2.SecurityGroup) pulumi.StringOutput {
return sg.ID()
}).(pulumi.StringOutput)
limited-rainbow-51650
04/06/2022, 5:02 PMnsg := cluster.NodeSecurityGroup.ID().ApplyT(func(id interface{}) string {
return id.(string)
}).(pulumi.StringOutput)
polite-napkin-90098
04/06/2022, 5:02 PMbored-oyster-3147
04/06/2022, 5:02 PMpolite-napkin-90098
04/06/2022, 5:04 PMDiagnostics:
pulumi:pulumi:Stack (EKS-EKS-test):
# EKS
./main.go:239:35: cluster.NodeSecurityGroup.ID undefined (type ec2.SecurityGroupOutput has no field or method ID)
./main.go:353:16: cannot use sg.CustomResourceState.ID() (type pulumi.IDOutput) as type string in return argument
polite-napkin-90098
04/06/2022, 5:05 PMpolite-napkin-90098
04/06/2022, 5:06 PMAnyOutput
to StringOutput
or IDOutput
to this list I believe as there's no easy way without applying another applier func
to it"polite-napkin-90098
04/06/2022, 5:07 PMpolite-napkin-90098
04/06/2022, 5:07 PMpolite-napkin-90098
04/06/2022, 5:09 PMbored-oyster-3147
04/06/2022, 5:09 PMpolite-napkin-90098
04/06/2022, 5:09 PMpolite-napkin-90098
04/06/2022, 5:11 PMbored-oyster-3147
04/06/2022, 5:23 PMCoreData
delegate is that it is an Output<CoreData> type that is then giving you an Output<string> inside the delegate so we need one the pulumi golang guys to go over how or what you're supposed to return from that delegate in order to unwrap the inner outputpolite-napkin-90098
04/06/2022, 5:25 PMbored-oyster-3147
04/06/2022, 5:30 PM// extract the role from the cluster output
iRole := cluster.Core.InstanceRoles().ApplyT(func(irole []*iam.Role) string {
return irole[0].Name
}).(pulumi.StringOutput)
polite-napkin-90098
04/06/2022, 7:21 PMpolite-napkin-90098
04/06/2022, 7:28 PMiRole := cluster.Core.InstanceRoles().ApplyT(func(irole []*iam.Role) pulumi.StringOutput{
return irole[0].Name
})
I now get panic: interface conversion: pulumi.Output is pulumi.AnyOutput, not iam.RoleArrayOutput
polite-napkin-90098
04/06/2022, 7:29 PMbored-oyster-3147
04/06/2022, 7:39 PMpolite-napkin-90098
04/06/2022, 7:39 PMpolite-napkin-90098
04/06/2022, 7:40 PMpolite-napkin-90098
04/06/2022, 7:41 PMcluster.Core.InstanceRoles.ApplyT undefined (type func() iam.RoleArrayOutput has no field or method ApplyT)
as that is what happens when when you leave the brackets out of cluster.Core.InstanceRoles.ApplyT
and not
cluster.Core.InstanceRoles().ApplyT
bored-oyster-3147
04/06/2022, 7:42 PMCoreDataOutput
type has no properties. It has functions only, that are used to access the properties of CoreData
.polite-napkin-90098
04/06/2022, 7:43 PMbored-oyster-3147
04/06/2022, 7:49 PMInstanceRoles()
you just have a standard iam.RoleArrayOutput
that you should be able to use normally as you would use it from the iam provider. For instance you could use this function to get a specific index of the array. So maybe cluster.core.InstanceRoles().Index(0).ApplyT(func(irole *iam.Role) string { return irole.Name });
or something like that.bored-oyster-3147
04/06/2022, 7:49 PMpolite-napkin-90098
04/06/2022, 7:50 PMpolite-napkin-90098
04/06/2022, 7:51 PMpulumi.IntInput
bored-oyster-3147
04/06/2022, 7:52 PMpolite-napkin-90098
04/06/2022, 8:04 PMvar index pulumi.IntInput = pulumi.IntInput(0)
iRole := cluster.Core.InstanceRoles().Index(index).ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return irole.Name
})
and some variations but I mostly get errors like
pulumi:pulumi:Stack (EKS-EKS-test):
# EKS
./main.go:411:46: cannot convert 0 (type int) to type pulumi.IntInput:
int does not implement pulumi.IntInput (missing ElementType method)
Which is the kind of thing which makes me long for polymorphismpolite-napkin-90098
04/06/2022, 8:06 PMiRole := cluster.Core.InstanceRoles().Index(pulumi.IntInput(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return irole.Name
})
is a simpler form, but it gives the same error.bored-oyster-3147
04/06/2022, 8:07 PM0.(pulumi.IntInput)
bored-oyster-3147
04/06/2022, 8:09 PM<http://pulumi.Int|pulumi.Int>(0)
that you wantpolite-napkin-90098
04/06/2022, 8:09 PM# EKS
./main.go:411:49: cannot call non-function 0 (type float64)
./main.go:411:50: type pulumi.IntInput is not an expression
polite-napkin-90098
04/06/2022, 8:09 PMbored-oyster-3147
04/06/2022, 8:09 PMcert.DomainValidationOptions.Index(<http://pulumi.Int|pulumi.Int>(0)).ResourceRecordValue().Elem(),
polite-napkin-90098
04/06/2022, 8:10 PMDiagnostics:
pulumi:pulumi:Stack (EKS-EKS-test):
error: an unhandled error occurred: program exited with non-zero exit code: 1
panic: interface conversion: pulumi.Output is pulumi.AnyOutput, not iam.RoleArrayOutput
goroutine 1 [running]:
<http://github.com/pulumi/pulumi-eks/sdk/go/eks.CoreDataOutput.InstanceRoles({0xc00024c1e0})|github.com/pulumi/pulumi-eks/sdk/go/eks.CoreDataOutput.InstanceRoles({0xc00024c1e0})>
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi-eks/sdk@v0.36.0/go/eks/pulumiTypes.go:947 +0x54
main.main.func1(0xc0000fa140)
/home/ubuntu/docker/EKS/pulumi/main.go:411 +0x3265
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunWithContext|github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunWithContext>(0xc0000fa140, 0x14d6720)
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:103 +0x199
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunErr(0x43efc5|github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunErr(0x43efc5>, {0x0, 0x0, 0xc0000001a0})
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:84 +0x310
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.Run(0x0|github.com/pulumi/pulumi/sdk/v3/go/pulumi.Run(0x0>, {0x0, 0x10cf680, 0xc0000001a0})
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:41 +0x25
main.main()
/home/ubuntu/docker/EKS/pulumi/main.go:18 +0x27
exit status 2
But somehow seems closerbored-oyster-3147
04/06/2022, 8:20 PMbored-oyster-3147
04/06/2022, 8:21 PMiRole := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).Name();
I'm seeing a lot of Property()
for things I think are properties in the golang sdk lolpolite-napkin-90098
04/06/2022, 8:24 PM./main.go:411:61: cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).Name undefined (type iam.RoleOutput has no field or method Name)
polite-napkin-90098
04/06/2022, 8:24 PMbored-oyster-3147
04/06/2022, 8:25 PMApplyT
doesn't change the fact that Name is a pulumi.StringOutput
inside the delegate so that isn't what we wantbored-oyster-3147
04/06/2022, 8:26 PMbored-oyster-3147
04/06/2022, 8:27 PM.Elem()
on the result of .Index(<http://pulumi.Int|pulumi.Int>(0))
give you for a type?polite-napkin-90098
04/06/2022, 8:32 PMiRole := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).Elem().ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return irole.Name
})
but that gives:
error: an unhandled error occurred: program exited with non-zero exit code: 2
# EKS
./main.go:411:61: cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).Elem undefined (type iam.RoleOutput has no field or method Elem)
bored-oyster-3147
04/06/2022, 8:38 PMeks.Cluster
We're trying to get the first element of the instance roles array on the eks.Cluster
. Using cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0))
gets us the first element of the RoleArrayOutput
returned by InstanceRoles()
. That first element is of type RoleOutput
. How do you get the .Name
property off of this element?polite-napkin-90098
04/06/2022, 8:40 PMbored-oyster-3147
04/06/2022, 8:41 PMlemon-agent-27707
04/06/2022, 8:51 PMcluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(...
lemon-agent-27707
04/06/2022, 8:51 PMElem
I don't thinkbored-oyster-3147
04/06/2022, 8:52 PM.Name
property was still a pulumi.StringOutput
inside the applylemon-agent-27707
04/06/2022, 10:14 PMRole
is a resource.lemon-agent-27707
04/06/2022, 10:15 PMName
output, and then a second apply on that result to manipulate the underlying value.lemon-agent-27707
04/06/2022, 10:16 PMname := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(...
nameResult := name.Apply(...
bored-oyster-3147
04/07/2022, 2:03 PMResource.PropertyOutput
so you could Role.Name.Apply(...)
but in this case it is ResourceOutput
so you have to Role.Apply(...)
which is very weird when he just wants to get the name and pass it around, he doesn't even want to manipulate the name. If it was just a resource he could just var roleName = Role.Name;
and he would be fine, no apply necessary. But since the role itself is an output, that isn't possible since .Name
isn't accessible.
@polite-napkin-90098 did you try doing:
iRole := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput {
return irole[0].Name
});
polite-napkin-90098
04/07/2022, 2:34 PMpolite-napkin-90098
04/07/2022, 3:20 PMpanic: interface conversion: pulumi.Output is pulumi.AnyOutput, not iam.RoleArrayOutput
error.polite-napkin-90098
04/07/2022, 3:21 PMiRole := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return irole.Name
})
polite-napkin-90098
04/07/2022, 4:51 PMbored-oyster-3147
04/07/2022, 6:03 PMpolite-napkin-90098
04/08/2022, 7:05 PMiRole := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return irole.Name.ToStringOutput
})
Which gives the error:
./main.go:412:21: cannot use irole.Name.ToStringOutput (type func() pulumi.StringOutput) as type pulumi.StringOutput in return argument
which seems to be progresspolite-napkin-90098
04/08/2022, 7:20 PMiRole := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return irole.Name.ToStringOutput()
}).ApplyT(func(iro interface{}) string {
return iro.(string)
}).(pulumi.StringOutput)
Which is similar to the Security Group example I posted a couple of days ago in this thread.
Unfortunately that errors with:
Diagnostics:
pulumi:pulumi:Stack (EKS-EKS-test):
panic: interface conversion: pulumi.Output is pulumi.AnyOutput, not iam.RoleArrayOutput
goroutine 1 [running]:
<http://github.com/pulumi/pulumi-eks/sdk/go/eks.CoreDataOutput.InstanceRoles({0xc0002121e0})|github.com/pulumi/pulumi-eks/sdk/go/eks.CoreDataOutput.InstanceRoles({0xc0002121e0})>
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi-eks/sdk@v0.36.0/go/eks/pulumiTypes.go:947 +0x54
main.main.func1(0xc0004b6000)
/home/ubuntu/docker/EKS/pulumi/main.go:411 +0x32a5
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunWithContext|github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunWithContext>(0xc0004b6000, 0x14d6af0)
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:103 +0x199
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunErr(0x43efc5|github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunErr(0x43efc5>, {0x0, 0x0, 0xc0000001a0})
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:84 +0x310
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.Run(0x0|github.com/pulumi/pulumi/sdk/v3/go/pulumi.Run(0x0>, {0x0, 0x10cf720, 0xc0000001a0})
/home/ubuntu/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.24.1/go/pulumi/run.go:41 +0x25
main.main()
/home/ubuntu/docker/EKS/pulumi/main.go:18 +0x27
exit status 2
So there's still some kind of type confusion going on 😬bored-oyster-3147
04/08/2022, 8:20 PMStringOutput
that you can pass around after the first. I mean this:
iRole := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput {
return irole.Name.ToStringOutput()
})
bored-oyster-3147
04/08/2022, 8:23 PM.ToStringOutput()
it at all implies that it is not in fact a string output inside the apply function so why the heck doesn't this work:
iRole := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) string {
return irole.Name
}).(pulumi.StringOutput)
I'm honestly really confused about thispolite-napkin-90098
04/08/2022, 8:30 PMpanic: interface conversion: pulumi.Output is pulumi.AnyOutput, not iam.RoleArrayOutput
for your first code block.polite-napkin-90098
04/08/2022, 8:30 PMpolite-napkin-90098
04/08/2022, 8:32 PMpolite-napkin-90098
04/08/2022, 8:39 PMfunc (o CoreDataOutput) InstanceRoles() iam.RoleArrayOutput {
return o.ApplyT(func(v CoreData) []*iam.Role { return v.InstanceRoles }).(iam.RoleArrayOutput)
}
This is the function in go/eks/pulumiTypes.go:947
which is barfing. I guess the Index() is after a pulumi.AnyOutput and not a iam.RoleArrayOutputpolite-napkin-90098
04/08/2022, 8:41 PMpolite-napkin-90098
04/08/2022, 8:49 PMiRole := cluster.Core.InstanceRoles().ApplyT(func(irole []*iam.Role) pulumi.StringOutput{
return irole[0].Name
}).(pulumi.StringOutput)
This also gives the: panic: interface conversion: pulumi.Output is pulumi.AnyOutput, not iam.RoleArrayOutput
polite-napkin-90098
04/08/2022, 8:49 PMpolite-napkin-90098
04/11/2022, 5:35 PMbored-oyster-3147
04/11/2022, 5:53 PMpolite-napkin-90098
04/11/2022, 6:04 PMlemon-agent-27707
04/12/2022, 1:02 AMStringOutput
There is a workaround here that you might be able to try: https://github.com/pulumi/pulumi/issues/6073#issuecomment-809669645polite-napkin-90098
04/12/2022, 1:28 PMpolite-napkin-90098
04/12/2022, 2:24 PM// extract the role from the cluster output
iRol, err := cluster.Core.InstanceRoles().ApplyT(func(irole []*iam.Role) pulumi.StringOutput{
return irole[0].Name.ToStringOutput()
}).(pulumi.AnyOutput), nil
if err != nil {
return err
}
iRole, err := iRol.ApplyT(func(iro interface{}) string {
return iro.(string)
}).(pulumi.StringOutput), nil
if err != nil {
return err
}
But both of them give the panic: interface conversion: pulumi.Output is pulumi.AnyOutput, not iam.RoleArrayOutput
which happens in the cluster.Core.InstanceRoles().ApplyT line.
Perhaps I need to use the Index(<http://pulumi.Int|pulumi.Int>(0))
and only pass the first role (there is only one in my case) into the ApplyT and then extract the pulumi.String from the pulumi.AnyOutputpolite-napkin-90098
04/12/2022, 2:27 PMiRol, err := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return irole.Name.ToStringOutput()
}).(pulumi.AnyOutput), nil
if err != nil {
return err
}
iRole, err := iRol.ApplyT(func(iro interface{}) string {
return iro.(string)
}).(pulumi.StringOutput), nil
if err != nil {
return err
}
polite-napkin-90098
04/12/2022, 2:27 PMpolite-napkin-90098
04/12/2022, 4:39 PMiRol, err := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return irole.Name
}).(pulumi.AnyOutput), nil
Also gives the interface conversion panic, and
iRol, err := cluster.Core.InstanceRoles().Index(<http://pulumi.Int|pulumi.Int>(0)).ApplyT(func(irole *iam.Role) pulumi.StringOutput{
return pulumi.String(irole.Name).ToStringOutput()
}).(pulumi.AnyOutput), nil
gives
./main.go:412:24: cannot convert irole.Name (type pulumi.StringOutput) to type pulumi.String
polite-napkin-90098
04/12/2022, 4:40 PMpolite-napkin-90098
04/12/2022, 4:40 PMpolite-napkin-90098
04/12/2022, 6:14 PMiRol, err := cluster.Core.ApplyT(func(irole *eks.CoreData) pulumi.StringOutput{
return irole.InstanceRoles[0].Name
}), nil
or similar functions which return the []*iam.Role or just the zeroth *iam.Role result in
panic: applier must have 1 input parameter assignable from eks.CoreData
which is another error I'm struggling to understand and google just leads me to
https://github.com/pulumi/pulumi-azure/issues/530 which doesn't help me much.polite-napkin-90098
04/21/2022, 7:52 PMbored-oyster-3147
04/22/2022, 12:40 AMpolite-napkin-90098
04/22/2022, 2:29 PMbored-oyster-3147
04/23/2022, 5:56 PMNo matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by