sst / ion

SST v3
https://sst.dev
MIT License
2.15k stars 249 forks source link

The argument "zone_id" is required #839

Open AlissonRS opened 2 months ago

AlissonRS commented 2 months ago

Hello!

My sst.config.ts looks like this (the run function):

  async run() {
    new sst.aws.Nextjs('MyApp', {
      domain: {
        name: 'app.mydomain.com',
        aliases: ['app-qa.mydomain.com'],
        cert: 'arn:aws:acm:us-east-1:123123123123123:certificate/9999999',
      }
    })
  },

It had been working fine for several weeks, but yesterday all of a sudden we started seeing this issue in our GitHub Actions pipelines:

✕ Failed
MyCompanyMyAppCdnAAAARecordmyappmycompanycom aws:route53:Record aws:route53/record:Record resource 'MyCompanyMyAppCdnAAAARecordmyappmycompanycom' has a problem: Missing required argument. The argument "zone_id" is required, but no definition was found.. Examine values at 'MyCompanyMyAppCdnAAAARecordmyappmycompanycom.zoneId'.

This is likely because in our pipelines we always install latest CLI:

      - name: Install SST
        run: curl -fsSL https://ion.sst.dev/install | bash

      - name: Unlock SST
        run: sst unlock --stage prod

      - name: Refresh
        run: sst refresh --stage prod

      - name: Deploy
        run: sst deploy --stage prod --verbose

So I'm assuming some new change in the CLI introduced this issue.

It's unclear to me where I should provide the zone_id, and I was also wondering if SST can't use AWS CLI to figure the zone_id automatically based on the domain name argument (e.g. mydomain.com).

Thanks for such a great new engine!

MaximilianSchon commented 2 months ago

We had this problem and removed and readded the domain assignments and is working fine since.

brunocleite commented 2 months ago

Had same problem here, must be something related to recent updates. Executing @MaximilianSchon solution solved the problem. I removed the domain, deployed, then added it again and deployed.

Although it keeps happening from now and then, I am not sure yet what triggers it.

AlissonRS commented 2 months ago

While not ideal, I managed to fix it by manually providing the zone_id (I found where to put it):

  async run() {
    new sst.aws.Nextjs('MyApp', {
      domain: {
        name: 'app.mydomain.com',
        dns: sst.aws.dns({
          zone: 'Z054050F045045A0540K',
        }),
        aliases: ['app-qa.mydomain.com'],
        cert: 'arn:aws:acm:us-east-1:123123123123123:certificate/9999999',
      }
    })
  },

Perhaps there is a way to fetch the zone_id given the hostname (using SST itself so we don't have to install AWS SDK). As much as it's something that should rarely change, it'd make it easier to copy + paste to other projects.

angelgarrido commented 2 months ago

zone should be mandatory only if there is some kind of conflict recovering the domain name (IE, you have more than one zone with the same domain)

AlissonRS commented 2 months ago

@angelgarrido that's strange, I have only one zone for the domain, and still experienced this issue.

Worth noting this was working fine for a long time, and stopping giving this error despite no changes to my hosted zones.

jayair commented 2 months ago

Hmm it would be good if we could replicate this to test it. Or @fwang might need some debug info to track this down.