When I use `aws.route53.Record.get(...)` to retrie...
# general
When I use
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)?
I would suggest: either manage the resource in pulumi or don’t. I’m pretty sure .get() is only for serialized lamdas etc.
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.
@big-piano-35669 Am I wrong about get() here? I thought I saw that somewhere in a jsdoc comment but it appears not.
Ahhh, I see! There are actually two
methods. (In hindsight, it's quite confusing and unfortunate that we named them both
!) 1. A static
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
method on all `Output<T>`s that is used to get the raw value of the property without needing an
(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
I see! TIL about (1). Thank you.
re: do we plan to fix this
We do :)
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).