https://pulumi.com logo
#general
Title
# general
h

handsome-truck-95168

12/11/2019, 8:18 PM
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

rhythmic-hair-33677

12/11/2019, 9:29 PM
I would suggest: either manage the resource in pulumi or don’t. I’m pretty sure .get() is only for serialized lamdas etc.
b

big-piano-35669

12/11/2019, 11:14 PM
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

rhythmic-hair-33677

12/11/2019, 11:30 PM
@big-piano-35669 Am I wrong about get() here? I thought I saw that somewhere in a jsdoc comment but it appears not.
b

big-piano-35669

12/11/2019, 11:34 PM
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

rhythmic-hair-33677

12/11/2019, 11:53 PM
I see! TIL about (1). Thank you.
m

microscopic-florist-22719

12/11/2019, 11:54 PM
re: do we plan to fix this
We do :)
h

handsome-truck-95168

12/13/2019, 5:32 PM
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).
12 Views