"Serverless Error: Rest API id could not be resolved." but Serverless service does not use Rest API resources

Hi,

I’m experiencing an intermittent issue when running serverless deploy. My configuration does not use API Gateway or any API-associated resources; however, I get the following issue:

Serverless Error ----------------------------------------

  Rest API id could not be resolved.

  This might be caused by a custom API Gateway configuration.

  In given setup stage specific options such as `tracing`, `logs` and `tags` are not supported.

  Please update your configuration (or open up an issue if you feel that there's a way to support your setup).

  Get Support --------------------------------------------

     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------

     Operating System:          linux
     Node Version:              10.16.3
     Framework Version:         2.31.0 (local)
     Plugin Version:            4.5.2
     SDK Version:               4.2.2
     Components Version:        3.7.7

Raising this here as I’m not sure whether this is a bug or an issue with my configuration, but I see this on some deployments but not others. Sometimes the issue is fixed after a redeploy.

My (trimmed and scrubbed) configuration:

service:
  name: utils
  prefix: lambdas

plugins:
  - serverless-plugin-ifelse
  - serverless-webpack
  - serverless-vpc-discovery
  - serverless-deployment-bucket
  - serverless-pseudo-parameters
  - serverless-plugin-lambda-dead-letter
  - serverless-plugin-tracing
  - serverless-prune-plugin
  - serverless-stack-termination-protection
  - serverless-plugin-lambda-insights

custom:
  stage: dummy

  versions_enabled:
    example: true

  serverless_deployment_s3_bucket_name:
    example: ${self:service.prefix}-example

  vpc:
    vpcName: example-${self:provider.stage}
    subnetNames:
      - Private_1a-1_${self:provider.stage}
      - Private_1b-1_${self:provider.stage}
    securityGroupNames:
      - serverless

  currentStage: ${self:provider.stage}
  
  serverlessIfElse:
    - If: '"${self:custom.currentStage}" == "local"'
      Exclude:
        - functions.example1
    - If: '"${opt:custom_stage, self:custom.stage}" == "example"'
      Set:
        - custom.lambdaInsights.defaultLambdaInsights: false
        - custom.prune.automatic: false

  prune:
    automatic: true
    includeLayers: true
    number: 5

  serverlessTerminationProtection:
    stages:
      - prod

  lambdaInsights:
    defaultLambdaInsights: true
    attachPolicy: false

provider:
  name: aws
  stackName: ${self:service.prefix}-${opt:stage}-${self:service.name}
  runtime: nodejs10.x
  stage: ${opt:custom_stage, opt:stage}
  tracing: true
  timeout: 30
  logRetentionInDays: 180
  deploymentBucket:
    role: arn:aws:iam::#{AWS::AccountId}:role/${self:service.prefix}-${self:provider.stage}-deploymentBucket-role
    name: ${self:custom.serverless_deployment_s3_bucket_name.${opt:stage, 'example'}, self:custom.serverless_deployment_s3_bucket_name.example}
    serverSideEncryption: AES256 # Server-side encryption method
    blockPublicAccess: true # Prevents public access via ACLs or bucket policies
  versionFunctions: true
  environment:
    STAGE: ${opt:stage, 'example'}
    NODE_ENV: production
    ENVIRONMENT: ${self:provider.stage}
    SUPPRESS_NO_CONFIG_WARNING: true
    ALLOW_CONFIG_MUTATIONS: true

functions:
  example1:
    role: arn:aws:iam::#{AWS::AccountId}:role/${self:service.prefix}-${self:provider.stage}-example1-role
    name: ${self:service.prefix}-${opt:stage}-v3-example1
    handler: handler-utils.example1
    tracing: false
    memorySize: ${ssm:/mxp-plus/${self:provider.stage}/example1_MEMORY~true}

  example2:
    role: arn:aws:iam::#{AWS::AccountId}:role/${self:service.prefix}-${self:provider.stage}-example2-role
    name: ${self:service.prefix}-${opt:stage}-v3-example2
    handler: handler-utils.example2
    tracing: false

The stack deploys correctly - this is the (trimmed and scrubbed) output:

(node:27279) ExperimentalWarning: The fs.promises API is experimental

(node:27279) ExperimentalWarning: The dns.promises API is experimental

Serverless: Deprecation warning: "provider.stage" is not accessible (configured behind variables which cannot be resolved at this stage).

            Starting with next major release, this will be communicated with a thrown error.

            Set "variablesResolutionMode: 20210219" in your service config, to adapt to this behavior now

            More Info: https://www.serverless.com/framework/docs/deprecations/#NEW_VARIABLES_RESOLVER

Serverless: Deprecation warning: Starting from next major object notation for "service" property will no longer be recognized. Set "service" property directly with service name.

            More Info: https://www.serverless.com/framework/docs/deprecations/#SERVICE_OBJECT_NOTATION

Serverless: Configuration warning:

Serverless:   at 'provider.deploymentBucket': unrecognized property 'role'

Serverless:   at 'provider.tracing': should be object

Serverless:   at 'service': unrecognized property 'prefix'

Serverless:  

Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation

Serverless:  

Serverless: Deprecation warning: Starting with next major, Serverless will throw on configuration errors by default. Adapt to this behavior now by adding "configValidationMode: error" to service configuration

            More Info: https://www.serverless.com/framework/docs/deprecations/#CONFIG_VALIDATION_MODE_DEFAULT

Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.

            Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"

            More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2

Serverless: Using deployment bucket 'example'

Serverless: Updating VPC config...

Serverless: Bundling with Webpack...

Hash: 0b783937fe08ace30a88

Version: webpack 4.46.0

Time: 170936ms

Built at: 04/08/2021 1:49:29 PM

                                   Asset      Size  Chunks                   Chunk Names

config/custom-environment-variables.json  8.27 KiB          [emitted]        

                     config/default.json  6.97 KiB          [emitted]        

            config/development-mock.json  5.38 KiB          [emitted]        

                 config/development.json  7.61 KiB          [emitted]        

                        handler-utils.js  21.1 MiB       0  [emitted]        handler-utils

                    handler-utils.js.map  12.6 MiB       0  [emitted] [dev]  handler-utils

Entrypoint handler-utils = handler-utils.js handler-utils.js.map

   [0] ./node_modules/aws-sdk/lib/core.js 2.43 KiB {0} [built]

   [1] ./node_modules/aws-sdk/lib/node_loader.js 3.88 KiB {0} [built]

   [4] ./node_modules/tslib/tslib.es6.js 10 KiB {0} [built]

   [7] ./node_modules/mxp-service-common/dist/index.js 1.37 KiB {0} [built]

  [10] external "fs" 42 bytes {0} [built]

  [11] ./node_modules/mxp-schemas/dist/index.js 2.95 KiB {0} [built]

  [14] ./node_modules/mxp-service-common/dist/lib/logger.js 5.7 KiB {0} [built]

  [18] external "path" 42 bytes {0} [built]

  [31] ./node_modules/mxp-utils/dist/index.js 3.07 KiB {0} [built]

 [115] ./node_modules/@sentry/node/esm/index.js + 46 modules 175 KiB {0} [built]

       | ./node_modules/@sentry/node/esm/index.js 1.44 KiB [built]

       | ./node_modules/@sentry/node/esm/version.js 118 bytes [built]

       | ./node_modules/@sentry/node/esm/transports/index.js 155 bytes [built]

       | ./node_modules/@sentry/node/esm/backend.js 4.64 KiB [built]

       | ./node_modules/@sentry/node/esm/client.js 1.38 KiB [built]

       | ./node_modules/@sentry/core/esm/index.js 698 bytes [built]

       | ./node_modules/@sentry/node/esm/handlers.js 9.88 KiB [built]

       | ./node_modules/@sentry/node/esm/integrations/index.js 309 bytes [built]

       | ./node_modules/@sentry/node/esm/sdk.js 4.63 KiB [built]

       | ./node_modules/@sentry/types/esm/severity.js 1.4 KiB [built]

       | ./node_modules/@sentry/types/esm/status.js 1.44 KiB [built]

       | ./node_modules/@sentry/hub/esm/scope.js 14.5 KiB [built]

       | ./node_modules/@sentry/types/esm/session.js 384 bytes [built]

       | ./node_modules/@sentry/hub/esm/session.js 3.14 KiB [built]

       | ./node_modules/@sentry/hub/esm/hub.js 15.5 KiB [built]

       |     + 32 hidden modules

 [150] ./node_modules/aws-sdk/lib/aws.js 159 bytes {0} [built]

 [212] ./node_modules/csvtojson/v2/index.js 281 bytes {0} [built]

 [342] ./node_modules/source-map-support/register.js 25 bytes {0} [built]

 [836] ./node_modules/source-map-support/source-map-support.js 19.3 KiB {0} [built]

[3574] ./handler-utils.ts + 13 modules 96.2 KiB {0} [built]

       | ./handler-utils.ts 1.12 KiB [built]

       | ./services/init.ts 2.87 KiB [built]

       | ./handlers/utils/functions/example1.ts 4.32 KiB [built]

       | ./handlers/utils/functions/example2.ts 571 bytes [built]

    + 3594 hidden modules

Serverless: Packaging service...

Serverless: Tracing DISABLED for function "example1"

Serverless: Tracing DISABLED for function "example2"

Serverless: Using deployment bucket 'example'

Serverless: Uploading CloudFormation file to S3...

Serverless: Uploading artifacts...

Serverless: Uploading service utils.zip file to S3 (7.14 MB)...

Serverless: Validating template...

Serverless: Creating Stack...

Serverless: Checking Stack create progress...

.................................................................

Serverless: Stack create finished...

Service Information

service: utils

stage: example

region: us-east-1

stack: example-utils

resources: 21

api keys:

  None

endpoints:

  None

functions:

  example1: lambdas-example1

  example2: lambdas-example2


layers:

  None

 

 Serverless Error ----------------------------------------

Rest API id could not be resolved.

  This might be caused by a custom API Gateway configuration.

  

  In given setup stage specific options such as `tracing`, `logs` and `tags` are not supported.

  

  Please update your configuration (or open up an issue if you feel that there's a way to support your setup).

 

  Get Support --------------------------------------------

     Docs:          docs.serverless.com

     Bugs:          github.com/serverless/serverless/issues

     Issues:        forum.serverless.com

 

  Your Environment Information ---------------------------

     Operating System:          linux

     Node Version:              10.16.3

     Framework Version:         2.31.0 (local)

     Plugin Version:            4.5.2

     SDK Version:               4.2.2

     Components Version:        3.7.7