I keep running into an issue when deploying a proj...
# sst
g
I keep running into an issue when deploying a project for the first time in a new account. I have a stack that creates a Route53 hosted zone, another stack that creates an API with a custom domain and a ReactSite with a custom domain. During the build step, the API and ReactSites throw the error below because the Hosted Zone is not yet instantiated.
Copy code
It seems you are configuring custom domains for you URL. And SST is not able to find the hosted zone "<http://qa.mydomain.com|qa.mydomain.com>" in your AWS Route 53 account. Please double check and make sure the zone exists, or pass in a different zone.
thoughts?
d
stacks have a method named
addDependency
for this purpose
otherwise they go in alphabetical order
g
I do use the addDependency…
it builds the route53 stack before the react and api stacks, but it doesn’t deploy the route53 stack before building the react and api stacks
d
i havent encountered this, but I have my Route53 in a separate app, it does sound like something SST related, though.
@Frank, just FYI, I was unable to help here, didnt wanna deter you guys from looking.
j
@Frank @thdxr Just bringing this to attention again.
f
Oh sorry guys… totally missed this
@Derek Kershner Thanks for looking into this!
@Guy Shechter so the
Api
construct calls
HostedZone.fromLookup()
, which makes an AWS SDK call to Route 53 to look up the hosted zone at build time. Since the zone hasn’t been deployed, hence the error. https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-route53.HostedZone.html#static-fromwbrlookupscope-id-query
Can I see how you are defining the
customDomain
?
g
That's right. But it doesn't exist because the dns zone hasn't been deployed yet since it's in a parallel stack
f
Right, can you share a snippet of your
customDomain
definition? I will give it a try on my end. (Most likely need to push out an update for this)
g
Will do. Thanks
In
PlatformStack.js
Copy code
this.hostedZone = new route53.HostedZone(this, 'route53zone', {
      zoneName: ( this.scope.stage === 'prod' )
          ? process.env.DOMAIN_NAME
          : `${ this.scope.stage }.${ process.env.DOMAIN_NAME }`,
    });
And in the
ApiStack.js
Copy code
const { hostedZone } = props;
this.api = new sst.Api(this, 'api', {
      customDomain: {
        domainName: `api.${ hostedZone.zoneName }`,
        hostedZone: hostedZone.zoneName,
        path: 'v1',
      },
        ....
}
Let me know if you need anything else @Frank
f
Hey @Guy Shechter sorry for the delayed response. If you haven’t worked around this issue, can you try this:
Copy code
const { hostedZone } = props;

this.api = new sst.Api(this, 'api', {
  customDomain: {
    domainName: `api.${ hostedZone.zoneName }`,
    hostedZone: hostedZone,
    path: 'v1',
  },
  ....
}
So pass in
hostedZone
directly into
customDomain.hostedZone
.
customDomain.hostedZone
takes both a string or a Route53.HostedZone construct. The latter is meant to handle this exact case.
Let me know if this works for you.
g
👍
I ran into something similar today, and took advantage of the auto-detection of the dependency, which I think operates on the same principle.
Copy code
const vpcStack = new VpcStack(app, "vpc");
const dbStack = new DatabaseStack(app, "db", {
    vpc: vpcStack.vpc
  });
I initially had dbStack look up the vpc by name, which also failed at build time.. passing in the reference ec2.Vpc fixed it.
d
It actually does not, just in case it matters. exporting and importing uses Cloudformation Exports, which creates a hard dependency between the two stacks (you cannot delete either stack without deleting both, for instance). Using SSM and the
from
constructs decouples them, and they will operate independently.
182 Views