Hi all, I deploy an app with a LB service. Pulumi...
# aws
b
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
which language SDK are you using?
b
typescript
b
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
yes, a previous run of my pulumi app
The problem comes from getResourceProperty on a chart
b
ahhh the loadbalancer is coming from helm?
or EKS?
b
yes and I need to get the elb resource to pass to the record
yes eks
b
can you share your code in a github gist?
b
yes
b
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
you're doing a
get
and creating the same record, that unfortunately won't work
b
actually the get should not be there, I was just trying something
b
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
I updated the gist. Anyway the get needs the id of the resource which makes no sense here
b
you should just be able to do this:
Copy code
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
you miss the elb here which is necessary
b
the ambassador service is creating the ELB, right?
b
yes
b
the the hostname of that ELB is available in Kubernetes
b
yes it’s created with the chart
b
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
I need to create an alias record to target the elb
the dns name of the elb is dynamic
b
I'm spinning up some infra to try get this working
b
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?