https://pulumi.com logo
#golang
Title
# golang
l

lively-dentist-84054

12/12/2021, 11:51 PM
hi! I'm trying to get access to the ID of the
NodeSecurityGroup
created by
eks.NewCluster
but the type returned is a
*SecurityGroupOutput
and I can't figure out how to get the ID output out of it to use with other resources
b

billowy-army-68599

12/12/2021, 11:58 PM
you should be able to just pass it to another resource, haev you tried? are you getting an error?
l

lively-dentist-84054

12/13/2021, 12:07 AM
I'm trying to get it to
NewVpcEndpoint
, which takes a
StringArrayInput
for the
SecurityGroupIds
field and it wasn't clear how to convert it as there's no
ToStringOutput
method on
SecurityGroupOutput
and no obvious
ToStringArray*
function for this
Copy code
./main.go:71:48: cannot use cluster.NodeSecurityGroup (type "<http://github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2|github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2>".SecurityGroupOutput) as type pulumi.StringInput in slice literal:
        "<http://github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2|github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2>".SecurityGroupOutput does not implement pulumi.StringInput (missing ToStringOutput method)
I worked around this with
Copy code
// HACK: cluster.NodeSecurityGroup is a SecurityGroupOutput that doesn't have an accessible ID
	nodeSecurityGroupTag := cluster.ToClusterOutput().ApplyT(func(_ *eks.Cluster) string {
		// use ApplyT to build a StringOutput that depends on cluster
		return prefix + "-nodeSecurityGroup"
	}).(pulumi.StringOutput)
	nodeSecurityGroup := ec2.LookupSecurityGroupOutput(ctx, ec2.LookupSecurityGroupOutputArgs{
		Tags: pulumi.StringMap{"Name": nodeSecurityGroupTag},
	})
should I file an issue somewhere describing this use case?
b

billowy-army-68599

12/14/2021, 4:32 PM
I think that would help, yes. thank you
l

lively-dentist-84054

12/14/2021, 4:32 PM
should it go in the eks repo or somewhere else?
b

billowy-army-68599

12/14/2021, 4:32 PM
EKS repo please!
👍🏻 1
l

lively-dentist-84054

12/14/2021, 4:45 PM
hopefully that's clear!
3 Views