amplify-education / serverless-domain-manager

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

Unable to update base path mapping #612

Closed varad11 closed 7 months ago

varad11 commented 8 months ago

Community Note

Bug Report

Error Description An error displayed telling V2 base path mapping update failed for my custom domain. But I have actually configured HTTP(V1) api instead of REST(V2),

Command Run sls deploy

Console Output

Error:
Error: V2 - Unable to update base path mapping for 'prefix.mydomain.com':
Invalid stage identifier specified
at APIGatewayV2Wrapper.<anonymous> (/usr/local/lib/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v2-wrapper.js:163:23)
at Generator.throw (<anonymous>)
at rejected (/usr/local/lib/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v2-wrapper.js:6:65)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

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

custom:
  customDomain:
    domainName: 'prefix.mydomain.com'
    basePath: ''
    certificateName: 'mydomain.com'
    createRoute53Record: true
    stage: 'production'
    endpointType: 'regional'
    apiType: http
    autoDomain: true

Versions

Possible Solution

Additional context/Screenshots I am using aws/codebuild/standard:6.0 Linux EC2

varad11 commented 8 months ago

A workaround temporarily is to revert back to an older serverless-domain-manager version 6.4.4

rddimon commented 7 months ago

Hi @varad11

Could you please also provide a function configuration?

Note: The quick fix for your case will be changing the customDomain.stage to $default.

It looks like not a good solution but I'm not quite sure what should be the right solution based on the next article: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html

It looks like we should always have $default stage before deploying anyone else

rsi-mrobinson commented 7 months ago

I ran into this as well during a migration from gitlab to github for CI. We do not use a $default stage and would prefer not to have one. Rolling back to 6.4.4 was a viable workaround, but I think if we can deploy successfully to aws using an earlier version with no $default stage, that indicates an issue with the plugin rather than a missing AWS requirement. Maybe I'm misreading this line though You can create a $default stage that is served from the base of your API's URL—for example, https://{api_id}.execute-api.{region}.amazonaws.com/. You use this URL to invoke an API stage.

tbh, we don't much care about the stage at all for apigateway as our environments are logically separated by accounts/vpcs and we are never invoking api's from the amazonaws.com endpoint, but I'd rather not have to add a dummy stage just to deploy.

rddimon commented 7 months ago

Hi @varad11 @rsi-mrobinson

Could you please try our latest version v7.3.5 ? And provide us the result

varad11 commented 7 months ago

@rddimon the latest version works without error for me. Thank you.

rsi-mrobinson commented 6 months ago

I've had the version pinned to 6.4.4 and must have missed this. I'm still seeing the issue on 7.3.5:

× Stack dev-proto-test-api failed to deploy (12s)
Error:
Error: V1 - Unable to fetch information about 'api.dev.my.endpoint.com':
Environment: linux, node 18.19.1, framework 3.38.0 (local) 3.37.0v (global), plugin 7.2.2, SDK 4.5.1
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

The security token included in the request is invalid.
    at APIGatewayV1Wrapper.<anonymous> (/__w/dev-proto-test-api/dev-proto-test-api/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v1-wrapper.js:77:27)
    at Generator.throw (<anonymous>)
    at rejected (/__w/dev-proto-test-api/dev-proto-test-api/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v1-wrapper.js:6:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
rddimon commented 6 months ago

Hi @rsi-mrobinson

  1. Error: V1 - Unable to fetch information about 'api.dev.my.endpoint.com'
  2. The security token included in the request is invalid.

Looks like there is an issue with your credentials and it's not related to the current issue Invalid stage identifier specified

rsi-mrobinson commented 6 months ago

Theres nothing wrong with the credentials being used, I rolled back package.json and package-lock.json to 6.4.4 and deployed the service with that version of the domain manager without issue. However, it does look like this may be an unrelated issue to this ticket. Let me know if you'd like me to spin off a fresh issue.

It looks like my implementation is using v1 of the wrapper as opposed to v2 as seen in varad's original ticket as well.

edit: created a new issue #621