This message was deleted.
# general
s
This message was deleted.
l
aws.getAutoscalingGroups
returns a Promise, you don't need to wrap that in an output. Just use
.then()
on it.
t
oh, interesting thought. thank you. i started with the example in the docs which did that but perhaps things have simplified since then. https://www.pulumi.com/docs/reference/pkg/aws/getautoscalinggroups/
ok, that produced desirable results:
Copy code
Updating (dev):
     Type                       Name          Status      
     pulumi:pulumi:Stack        gcso-k8-dev               
 +   β”œβ”€ aws:ec2:LaunchTemplate  bar1-b806b39  created     
 +   └─ aws:ec2:LaunchTemplate  bar2-cd01f02  created
thank you, sir.
πŸ‘ 1
i think i assumed that the portion of the example i used would work in my situation where i was trying to resolve the promise differently. and i assumed that
pulumi.output()
actually handled promises.
g
pulumi.output
does handle promises, but you have to resolve it with an
apply
(like
.then()
for Outputs)
i.e.
Copy code
asgs.apply(v => {...})
l
Related question: is there a benefit of wrapping the Promise with an Output in this case? The only one I can think of is that it allows a simple
pulumi.all
refer to the results, alongside lots of other outputs...
g
You can use Promises directly in the
all
, so it’s not necessary in this case. For example:
Copy code
const foo = new Promise(resolve => resolve("foo"))
export const fooValue = pulumi.all([foo]).apply(([v]) => v)
results in
Copy code
Outputs:
    fooValue: "foo"
l
Nice.
t
Interesting. Clearly I did not well grasp
pulumi.output
&
.apply()
. I may experiment with this more. Thank you. Seems to accomplish my stated example, I would probably need to stack the behavior as so: 1. preview and bulid ASGs in a way that I need a promise. 2. resolve the promise to query AWS for the ASGs. i know that shouldn't be necessary but this is for testing behavior for a much larger project. 3. resolve the promise from #2 to begin building resources as a consequence of the returned ASG list.