amplify-education / serverless-domain-manager

Serverless plugin for managing custom domains with API Gateways.
MIT License
939 stars 232 forks source link

Wrongly attempts to make APIGatewayV2 domain for a V1 rest api #640

Open kferrone opened 1 month ago

kferrone commented 1 month ago

Community Note

Bug Report

Error Description Wrongly attempts to make APIGatewayV2 domain for a V1 rest api. The api gateway created by serverless is for sure a REST api with EDGE endpoint type.

Command Run e.g. sls deploy, sls create_domain, etc.

Happens when deploy or create_domain and the same exact error will occur.

Console Output

✖ Stack the-app-dev01 failed to deploy (4s)

✖ Error: Unable to create domain 'patient-dev01.example.com':
V2 - Failed to create custom domain 'patient-dev01.example.com':
EDGE endpoint type is not supported for APIGatewayV2 domainName
    at ServerlessCustomDomain.<anonymous> (/Users/me/workspaces/them/functions/the-app/node_modules/serverless-domain-manager/dist/src/index.js:253:23)
    at Generator.throw (<anonymous>)
    at rejected (/Users/me/workspaces/them/functions/the-app/node_modules/serverless-domain-manager/dist/src/index.js:6:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Domain Manager Configuration Replace this with your own serverless.yml file (anonymized, of course) to help us better resolve your issue.

provider:
  name: aws
  runtime: nodejs20.x
  timeout: 30  
  stage: dev01
  region: us-west-2
  apiName: foobar-dev01-patient
  endpointType: EDGE
  environment:
    NODE_ENV: foobar-${opt:stage}-env
    NODE_PATH: "/var/task/src/"
  iam:
    role: arn:aws:iam::${aws:accountId}:role/foobar-${opt:stage}
  vpc:
    securityGroupIds: 
      "Fn::Split":
        - ","
        - ${ssm:/${opt:stage}/security-groups}
    subnetIds: 
      "Fn::Split":
        - ","
        - ${ssm:/${opt:stage}/private-subnets}
custom:
  customDomain:
    domainName: patient-${opt:stage}.${ssm:/${opt:stage}/domain-suffix}
    basePath: '/'
    stage: ${opt:stage}
    createRoute53Record: true
    apiType: rest # shouldn't this be enough to tell it's a v1 rest api?
    endpointType: EDGE
    securityPolicy: TLS_1_2
    certificateName: "*.${ssm:/${opt:stage}/domain-suffix}"
    hostedZoneName: ${ssm:/${opt:stage}/domain-suffix}
    autoDomain: true

Versions

Possible Solution

Additional context/Screenshots Add any other context about the problem here. If applicable, add screenshots to help explain.

Created a cert of type RSA in us-east-1. The sls app already existed before adding this plugin. I verified the actual api gateway is created as an REST with edge endpoint. The route53 record, in our case, absolutely must be an Alias A record, if cname then some automation will swiftly delete it.

kferrone commented 1 month ago

Ok . . . ? I got something to do something. I set endpoint type to regional and somehow I got a REGIONAL domain to an EDGE Rest API. I did not expect this to be possible. What does a regional domain to edge api even mean?

customDomain:
  endpointType: REGIONAL

How active is this project anyway? I have some strict deadlines and this bug is blocking me from getting what we truly want here. At least I have some workaround above, not the best answer though. How likely is someone to fix this issue verse other issues taking priority and this becoming stale?