When I use `aws.route53.Record.get(...)` to retrie...
# general
h
When I use
aws.route53.Record.get(...)
to retrieve a record that doesn't exist (in which case I would create it), my
pulumi up
fails with an error message like:
Copy code
error: Preview failed: resource 'Z22LJ5YIATCQQQ_<http://consolex.dev.example.com|consolex.dev.example.com>_CNAME' does not exist
Is there another way to see if a DNS record already exists? Do I need to use the AWS SDK (from Amazon)?
r
I would suggest: either manage the resource in pulumi or don’t. I’m pretty sure .get() is only for serialized lamdas etc.
b
This sounds like https://github.com/pulumi/pulumi/issues/3364. @microscopic-florist-22719 is this on the docket to fix for 2.0? In the meantime, using the AWS SDK is a good workaround.
r
@big-piano-35669 Am I wrong about get() here? I thought I saw that somewhere in a jsdoc comment but it appears not.
b
Ahhh, I see! There are actually two
get
methods. (In hindsight, it's quite confusing and unfortunate that we named them both
get
!) 1. A static
get
method on all resource types that looks up a resource by ID and/or properties, but does not lead to Pulumi managing that resource 2. An instance
get
method on all `Output<T>`s that is used to get the raw value of the property without needing an
apply
(as you say, typically used with lambda closure capture) Justin's question seems to be about (1). His scenario was actually an intended use case -- but we made it impossible by not letting you catch the errors 😕
👍 1
r
I see! TIL about (1). Thank you.
m
re: do we plan to fix this
We do :)
h
Ok that's great news. I had wrapped that code in try/catch but as you say - I never saw the error. That said, @rhythmic-hair-33677 comment did lead me to re-think how I was managing resources. Mostly I was fighting with dealing with legacy resources (created pre-pulumi). So I put in some logic that detects when I'm using those resources and I dont bother creating records (or retrieving them).