This message was deleted.
# general
s
This message was deleted.
l
You have to use the StringPtrOutput: the value returned isn't known synchronously, you cannot get at it in normal code.
You can either create your launch template in an
apply
block, or let Pulumi create the LaunchTemplate (if it is a supported resource type?)
g
Thanks for such quick reply 🙂 About this apply block - I understand that the function passed to
Apply
method should get this StringPtrOutput, and then try to call
Elem()
inside? I still just have to pass
StringOutput
to the
LaunchTemplateArgs
l
I'm just looking at the resources now.. are you using Pulumi's
LaunchTemplate
resource?
g
LaunchTemplate
is defined in
ec2
package, is that what you're asking?
l
You wouldn't use an
Apply
block to create one of those...
Yes.
It looks like those security group ids should be inputs, not strings... looking into the code...
Yep, in the node.js implementation, they are inputs, so it should just work...
g
Copy code
LaunchTemplateNetworkInterfaceArgs {
...
SecurityGroups pulumi.StringArrayInput
...
}
l
And can you not pass a real array with a
StringInput
member in there? That's how it would work in TypeScript...
g
StringPtrOutput
can't be casted to
StringInput
and I get
StringPtrOutput
from this
eksCluster.VpcConfig.ToClusterVpcConfigOutput().ClusterSecurityGroupId()
l
Ah.. not an issue in TypeScript... sorry, I've mislead you...
g
I guess in TypeScript implementation async stuff is working different
so the types and their relations are different
l
I think it's the idea of pointers to strings vs simple strings...
g
I pasted you some code of this
LaunchTemplateNetworkInterfaceArgs
- what is interesting, some fields there are of
StringPtrInput
type
for example
PrivateIpAddress
but
SecurityGroups
field is of
StringArrayInput
, not
StringPtrArrayInput
such type
StringPtrArrayInput
does not even exist
l
Is there a standard way of passing StringPtr(Input/Output) to a StringInput parameter? If not, then it may well be a bug; the equivalent would work in TypeScript/node code.
g
there is an error when trying to do this:
cannot use value of type pulumi.StringPtrOutpu as pulumi.StringInput value in array or slice literal: missing method ToStringOutput()
an indeed, looking into the code
StringPtrOutput
does not have method
ToStringOutput
, it has only
Elem()
method
which returns
StringOutput
, but also causes program to panic because of uninitialized pointer dereference
in desperation, I've even tried to wrap this in structure with defined method
ToStringOutput
, but as I had put the same code there as is in the
Elem()
function it ents up the same: panic
l
It looks like it should work.. are you calling
Elem()
where you're calling NewLaunchTemplate? Similar to the way it's done in the 2nd code snippet here? https://www.pulumi.com/docs/intro/concepts/programming-model/#lifting
g
this is simplified code, shortened to remove clutter:
launchTemplateArgs := ec2.LaunchTemplateArgs{
NetworkInterfaces: ec2.LaunchTemplateNetworkInterfaceArray{
ec2.LaunchTemplateNetworkInterfaceArgs{
DeviceIndex: pulumi.IntPtr(0),
SecurityGroups: pulumi.StringArray{
eksCluster.VpcConfig.ToClusterVpcConfigOutput().ClusterSecurityGroupId().Elem(),
},
},
},
}
launchTemplate, err := ec2.NewLaunchTemplate(ctx, ..., &launchTemplateArgs)
not sure which exactly snippet do you refer to, I see only one with
Elem
method, something with route53, is this the one?
l
I'm not a golang user, so this may be obvious, but: why do you use
eksCluster.VpcConfig.ToClusterVpcConfigOutput().ClusterSecurityGroupId().Elem()
instead of
eksCluster.VpcConfig.ClusterSecurityGroupId()
? Or maybe
eksCluster.VpcConfig.ClusterSecurityGroupId().Elem()
?
g
sorry, this was some attempt, in general I try to use ``eksCluster.VpcConfig.ClusterSecurityGroupId()``
l
Same behaviour in this case?
g
this
ToClusterVpcConfigOutput()
seems to do nothing, let's forget I've put it there
yes, tried first with this
ToClusterVpcConfigOutput()
then without
still, I can't just use
eksCluster.VpcConfig.ClusterSecurityGroupId()
because it returns
StringPtrOutput
and what I have to pass is
StringInput
interface
l
And
eksCluster.VpcConfig.ClusterSecurityGroupId().Elem()
causes the same panic? I'd raise an issue on GitHub.
g
this interface has method
ToStringOutput()
and the ``StringPtrOutput` does not implement this method
eksCluster.VpcConfig.ClusterSecurityGroupId().Elem()
causes panic,
eksCluster.VpcConfig.ClusterSecurityGroupId()
just does not compile because of the issue I've just described
do you think it's worth to wait for some pulumi+go veteran here, or just raise an issue?
l
Both, probably 🙂 If a panic can be raised, they'll probably want to resolve it, which means they'll need an issue to track...
g
ok, so I will watch the thread, and raise an issue tomorrow (now it's too late in Poland, time to go to sleep... ). Still, big thanks for your time and help :)
👍 1
help in my issue still appreciated 😉 TLDR all the replies maybe as we haven't found any solution so far, it looks like a bug, but would be really nice some Golang user could take a look 😉
c
@gray-xylophone-22620 Can you please open a git issue here since the panic should not happen with steps to replicate?
g
sure, I will 😉
c
@gray-xylophone-22620, Thanks for opening the ticket. If you can, please post the full code for reproduction.