Hey folks, I'm having a bit of trouble understandi...
# aws
m
Hey folks, I'm having a bit of trouble understanding the two different ways of
getting
an existing resource, for example: • one can use the function:
aws.service.get_resource()
• or the static method:
aws.service.Resource.get()
E.g., to get an existing S3 bucket, one can do:
aws.s3.get_bucket(bucket='myBucket')
or
aws.s3.Bucket.get(resource_name='myBucket', id=123456)
. What's the difference between the 2? Is there any caveat of using one over the other that I'm not aware of?
g
m
thanks @great-sunset-355, I'll check those links out!
g
in general, I tend to avoid
resource.get
because in past it had some weird consequences (I do not remember now, sorry) and use
get_resource
or rather
get_resource_output
which works as expected
m
is there any advantage of using
get_resource_output
over
get_resource
? The whole input / output thing is still a bit esoteric to me. I find that whenever I need a resource value (e.g. the ID), most times I have to
apply()
to use it.
l
The get_resource functions return (your language's version of) a promise, which you have to handle in the normal way. The get_resource_output functions wrap those promises in outputs. The primary benefit of this is member lifting: you can pass a value inside the output object into a Pulumi resource constructor without waiting for the promise to resolve.