https://pulumi.com logo
#general
Title
# general
g

green-kilobyte-86931

11/24/2022, 1:21 PM
Hello, I've been wrangling with Pulumi for a while now trying to solve this problem, one of my components is outputting a map of resource IDs, these IDs are then used in another component to create associated resources. The issue is that I cannot figure out a way to loop over a pulumi.MapInput type or any other iterable type. I understand that I can unpack an output and work with its raw values inside an applyT, however it is not recommended to create resources inside it. I also attempted to work around this by essentially copying the raw map contents from inside applyT to an external map, with no success. Is there a way to do this? I found a few issues discussing this topic, but couldn't find any satisfying answers.
v

victorious-church-57397

11/24/2022, 1:27 PM
could you share the code for the component which is outputting the map?
g

green-kilobyte-86931

11/24/2022, 1:32 PM
Copy code
func(subnets map[string]*ec2.Subnet) pulumi.MapOutput {
		subnetOutputs := make(map[string]pulumi.Output)
		for k, v := range subnets {
			subnetOutputs[k] = v.ID()
		}
		return pulumi.ToMapOutput(subnetOutputs)
I cannot share the whole component, but I can successfully print these values inside of an applyT of the consuming component
v

victorious-church-57397

11/24/2022, 4:41 PM
ah is this in go? sorry i use the TS implementation, not too au fait with go