Hey has anyone had issues before where they were u...
# help
n
Hey has anyone had issues before where they were unable to deploy stacks locally, whenever I try to deploy I get the following error. See thread for more context
Copy code
Cannot convert undefined or null to object
Full deploy message
It seems to be something to do with me adding apiEndpoints in my CFN exports, as soon as I comment these out it works fine
r
It might be because what you've added is one of the default exports that SST provides and, as such, it's complaining about the duplication
n
I only have two stacks atm as well, and one of them is sharing the others apigateway domain so that I can have
<http://mydomain.com/stack1|mydomain.com/stack1> & <http://mydomain.com/stack2|mydomain.com/stack2>
Ahh as in the name im chosing for the export is a conflicting name?
r
Possibly, if you run it without your own exports, I would expect to see the API endpoints for both stacks anyway. Is that what happens?
n
Changed name of CFN exports and no change. And actually seems now that even when I remove the exports the issue persists, just without the duplication message
Hmmm what does seem to fix it is when i comment out the customDomain section of my api's, i am attempting to achieve a similar setup as described here in the docs. Not sure what I am doing wrong though
Just adding to this for future travellers, I think the issue is fixed now, and it stemmed from me trying to define the custom domain for both my apis as
Copy code
{
  domainName: apiGatewayDomain || `api.${URL}`,
  hostedZone: apiGatewayDomain ? undefined : URL,
  path: serviceName.toLowerCase(),
}
When trying to give my apis a customDomain, the
hostedZone
property seemed to throw an error even if it is declared as undefined. I need to declare hosted zone on the first api I setup, however after this, all which use the apiGatewayDomain should not reference a hostedZone property at all
Scratch that started having the issue again 🤦‍♂️
f
@Noah D are you still having this problem?
When you get this error again, can you share two things? • ur stack definition in SST; and • the generated CloudFormation template json files in
.build/cdk.out
n
Hey @Frank, yea still experiencing this issue unfortunately, please see attached my template and stack definition files, and the function
getUrlForStage
is defined as follows
Copy code
const getUrlForStage = (
  stage: string,
  serviceName: string,
  apiGatewayDomain?: DomainName,
): ApiCustomDomainProps => {
  if (stage === DeploymentStage.Prod) {
    return {
      domainName: apiGatewayDomain || `api.${URL}`,
      hostedZone: apiGatewayDomain ? undefined : URL,
      path: serviceName.toLowerCase(),
    };
  }

  return {
    domainName: apiGatewayDomain || `${stage}.api.${URL}`,
    hostedZone: apiGatewayDomain ? undefined : URL,
    path: serviceName.toLowerCase(),
  };
};
Also worth noting I am on SST V0.53.0 for both cli & resources
Maybe something else worth noting too, is that when I deploy to seed & a dev stage, it seems to work completely fine, so may be something specific to local development. I have also removed & recreated my stack many times at this point, so don't think it is the stack in a bad state sorta thing. The only time I got close to fixing it, was when I changed the definition of the
customDomain
property to not include
hostedZone
for the stack which was dependant on the
apiGatewayDomain
however seemed to start happening again soon after and not sure what I did to break it
f
Hey @Noah D, so I looked at the stacks and their templates, they seem fine. It makes me believe that your CloudFormation console was probably in a weird state.
I’m not sure if you can still reproduce this issue. If you can, or the next time you run into this, run
aws cloudformation list-exports
from your terminal to list out all the Export outputs in the account/region. And then look for the export with the name that CloudFormation claims already exists, ie.
noah-mend-journal:ExportsOutputRefjournalApiDomainName1FC606F266B7C5E9
This should tell us clearly which stack currently has an export with the same name.
n
Ok so just started having this issue again unfortunately, ran that command you mentioned @Frank