https://pulumi.com logo
Title
b

bumpy-laptop-30846

04/14/2021, 4:52 PM
Hi all, I deploy an app with a LB service. Pulumi waits for it and then I want to do something with the service status. In this second step, I then need pulumi to manage another resource (acutally a route53 record). Does pulumi manage this multi step / asynchronous architecture? Currently, if the record is already there, I get an error: * [ERR]: Error building changeset: InvalidChangeBatch: [Tried to create resource record set [name=‘xxxxx’, type=‘A’] but it already exists] I don’t see a way to check if the record exists beforehand. Any idea on how to not have the app fail? Actually it’s more a general question even if my use case is with aws resources.
b

billowy-army-68599

04/14/2021, 4:56 PM
which language SDK are you using?
b

bumpy-laptop-30846

04/14/2021, 4:57 PM
typescript
b

billowy-army-68599

04/14/2021, 4:57 PM
if you pass the output from your LB to your route53 record, it should create the dependency graph correctly. In your case, it looks like a record already exists somehow? Do you know where that record is coming from?
b

bumpy-laptop-30846

04/14/2021, 4:58 PM
yes, a previous run of my pulumi app
The problem comes from getResourceProperty on a chart
b

billowy-army-68599

04/14/2021, 5:01 PM
ahhh the loadbalancer is coming from helm?
or EKS?
b

bumpy-laptop-30846

04/14/2021, 5:01 PM
yes and I need to get the elb resource to pass to the record
yes eks
b

billowy-army-68599

04/14/2021, 5:02 PM
can you share your code in a github gist?
b

bumpy-laptop-30846

04/14/2021, 5:02 PM
yes
b

billowy-army-68599

04/14/2021, 5:03 PM
while you're doing that, I will say that I generally actually give this responsibility to Kubernetes rather than Pulumi, and use this to do it: https://github.com/kubernetes-sigs/external-dns it will automatically populate DNS records from Kubernetes services
b

billowy-army-68599

04/14/2021, 5:07 PM
you're doing a
get
and creating the same record, that unfortunately won't work
b

bumpy-laptop-30846

04/14/2021, 5:07 PM
actually the get should not be there, I was just trying something
b

billowy-army-68599

04/14/2021, 5:08 PM
you can't do checks like this to determine if values exist within Pulumi, you'll have to use the native AWS SDK in TypeScript to verify if this exists, but you shouldn't need to do it
b

bumpy-laptop-30846

04/14/2021, 5:09 PM
I updated the gist. Anyway the get needs the id of the resource which makes no sense here
b

billowy-army-68599

04/14/2021, 5:10 PM
you should just be able to do this:
const status = await ambassador.getResourceProperty( "v1/Service", 'default', "ambassador", "status" );
const hostname = status.loadBalancer.ingress[0].hostname;
const zone = await aws.route53.getZone( { name: 'xxx.xx' } );

hostname.apply( async name => {
new aws.route53.Record( `api${ pulumi.getStack() }.xxx.x`, {
      zoneId: zone.zoneId,
      name: `api${ pulumi.getStack() }.xxx.xx`,
      type: "A",
      aliases: [ { evaluateTargetHealth: false, name: name, zoneId: elb.zoneId } ],
    } );
  } );
(untested)
b

bumpy-laptop-30846

04/14/2021, 5:12 PM
you miss the elb here which is necessary
b

billowy-army-68599

04/14/2021, 5:13 PM
the ambassador service is creating the ELB, right?
b

bumpy-laptop-30846

04/14/2021, 5:13 PM
yes
b

billowy-army-68599

04/14/2021, 5:13 PM
the the hostname of that ELB is available in Kubernetes
b

bumpy-laptop-30846

04/14/2021, 5:13 PM
yes it’s created with the chart
b

billowy-army-68599

04/14/2021, 5:14 PM
perhaps I'm missing something, why do you need to get the ELB? the A record only needs a DNS name, which you already have from the chart
b

bumpy-laptop-30846

04/14/2021, 5:14 PM
I need to create an alias record to target the elb
the dns name of the elb is dynamic
b

billowy-army-68599

04/14/2021, 5:37 PM
I'm spinning up some infra to try get this working
b

bumpy-laptop-30846

04/14/2021, 6:39 PM
ok cool, thanks!
I wonder if it’s a bug because I see the resource in my stack. Pulumi should see it and not try to create it again. What do you think?