I have a question about StackReferences and type c...
# golang
s
I have a question about StackReferences and type conversions in Go. I have an array of AWS subnet IDs that I am exporting (via
ctx.Export("subnetIds", pulumi.StringArray("subnets"))
in one stack. In another stack, I'd like to use a StackReference to pull that data out, but I'd like for it to just be a plain, ordinary array of strings so that I can iterate over it. Is there any way to do that?
l
What are you trying to do with them? Apply is always an option. Also, Automation API allows you to access stack references synchronously.
s
Hey Evan! The code I got from you a while back (which involves the use of
ApplyStringArray
) still generates an array of type
OutputArray
, which can't be iterated over. The ultimate end goal is to use these values either in some
kustomize
Transformations or to write them into a YAML file.
c
@salmon-account-74572 if you will use the automation API you could access the outputs of one stack and transform them to strings / array whatever:
Copy code
outputs, _ := stack.Outputs(ctx)
val, ok := outputs["someExportVar"]
if !ok {
	return nil, errors.New("previous stack didn't output 'someExportVar' value")
}
v := val.Value.(string)