https://pulumi.com logo
#python
Title
# python
c

crooked-pillow-11944

09/13/2021, 1:33 AM
I'm trying to handle output in the form of a list/dict:
Copy code
+ subnets: [
+     [0]: "10.2.0.0/22"
+     [1]: "10.4.0.0/22"
+     [2]: "10.6.0.0/22"
+     [3]: "10.8.0.0/22"
+     [4]: "10.10.0.0/22"
+     [5]: "10.12.0.0/22"
+     [6]: "10.14.0.0/22"
]
I can set a value by using the index (i.e.
['subnets'][0]
) I want to iterate over the subnets to create them but I can't use a for loop because
'Output' object is not iterable
How can I use these values in the output?
Using
.apply
with a lambda allows me to extract the values but now I need to figure out how to get those as values for new resources
Copy code
vpc_subnets = vpc['subnets'].apply(
   lambda x: list(map(print, x))
)
b

billowy-army-68599

09/13/2021, 4:55 AM
@crooked-pillow-11944 you can pass the whole array as an output, if you need specific elements from it you'll need to be a bit more creative..
c

crooked-pillow-11944

09/13/2021, 2:27 PM
I've considered putting the length of an Output list into another Output so that it can be used as an iterator but got this:
TypeError: 'Output' object cannot be interpreted as an integer
b

billowy-army-68599

09/13/2021, 4:01 PM
You can’t iterate over an output because it’s a future
c

crooked-pillow-11944

09/13/2021, 4:31 PM
That's what I figured
2 Views