amplify-education / serverless-domain-manager

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

Error: Failed to find a stack xxx #599

Closed erolabzait closed 12 months ago

erolabzait commented 12 months ago

Bug Report

Hello,

I am currently encountering an issue when attempting to deploy an API service that exports an api gateway for other services to use. Something similar to: https://github.com/GorillaStack/splitstack-postsapi but for the HTTP Api (V2)

Command Run I use the latest version of the plugin. sls deploy

Console Output

Error: Failed to find a stack xxx

    at CloudFormationWrapper.<anonymous> (.../xxx/services/api/node_modules/serverless-domain-manager/dist/src/aws/cloud-formation-wrapper.js:103:23)
    at Generator.next (<anonymous>)
    at fulfilled (.../xxx/services/api/node_modules/serverless-domain-manager/dist/src/aws/cloud-formation-wrapper.js:8:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Best regards,

erolabzait commented 12 months ago

Hello again,

I was able to fix it. I was defining an api gateway with resource 'StoreApiGateway'.

Resources:
  StoreApiGateway:
    Type: AWS::ApiGatewayV2::Api
    Properties:
      Name: '${self:service}-${sls:stage}'
      ProtocolType: HTTP
      CorsConfiguration:

It seems that the plugin is searching for one of this 3 values HttpApi | ApiGatewayRestApi | WebsocketsApi in the cloudformation output. You can find more details here https://github.com/amplify-education/serverless-domain-manager/issues/222

// Cloud Formation Resource Ids
public static CFResourceIds = {
    [Globals.apiTypes.http]: "HttpApi",
    [Globals.apiTypes.rest]: "ApiGatewayRestApi",
    [Globals.apiTypes.websocket]: "WebsocketsApi",
};

So i had to rename StoreApiGatewayHttpApi, this means it will create a new api (with a new api id) when you deploy 💔

Resources:
  HttpApi:
    Type: AWS::ApiGatewayV2::Api
    Properties:
      Name: '${self:service}-${sls:stage}'
      ProtocolType: HTTP
      CorsConfiguration:

It will be nice to have an option to set a different name then HttpApi. Something like:

custom:
  customDomain:
    domainName: serverless.foo.com
    stage: ci
    ...
    customCFIdentifier: 'StoreApiGateway'

Thanks for this awesome plugin, 👍