serverless-aws-alias icon indicating copy to clipboard operation
serverless-aws-alias copied to clipboard

Build fails: Export 'projectName-stageName-ServerlessAliasReference' does not exist

Open Abhijith-Nagaraja opened this issue 3 years ago • 11 comments

I am just getting started with serverless-aws-alias. But as soon as I include this plugin my build fails

Version: 1.8.0

Command: sls deploy

Error Details

 Serverless Error ---------------------------------------
 
  Export 'projectName-stageName-ServerlessAliasReference' does not exist.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              12.18.2
     Framework Version:         2.21.1
     Plugin Version:            4.4.2
     SDK Version:               2.3.2
     Components Version:        3.6.0

Serverless.yaml

service: projectName

frameworkVersion: '2'

plugins:
  - serverless-vpc-discovery
  - serverless-aws-alias

custom: ${file(../config-serverless/config.yml)}

package:
  individually: true
  exclude:
    - ".*/**"

provider:
  name: aws
  runtime: nodejs12.x
  lambdaHashingVersion: 20201221

  stage: ${self:custom.stage}
  region: ${self:custom.region}

functions:
  function1:
    handler: lambdas/function1/function1.function1
    layers:
      - {Ref: CommonLambdaLayer}
    package:
      include:
        - lambdas/elasticStatus/**

layers:
  common:
    path: layers/common
    name: common-${self:provider.stage}
    description: A common wrapper for all the helios code
    package:
      include:
        - layers/common/**

This may be related to this issue: https://github.com/serverless-heaven/serverless-aws-alias/issues/181 and https://github.com/serverless-heaven/serverless-aws-alias/pull/186

I also applied the fix provided by @Enase in here https://github.com/serverless-heaven/serverless-aws-alias/pull/186#issuecomment-762337467 but that also did not help.

One of issue tagged here mention here about roles, and also fix provided by @Enase is also for roles. But I am not mentioning role at function level or at provider level. Is that mandatory?

Abhijith-Nagaraja avatar Feb 04 '21 17:02 Abhijith-Nagaraja

what is the command you run?

Enase avatar Feb 04 '21 17:02 Enase

@Enase : sls deploy

Abhijith-Nagaraja avatar Feb 04 '21 17:02 Abhijith-Nagaraja

@Enase : Update. I ran with SLS_DEBUG on and set the level to verbose.... so here is the updated error report

Serverless Error ---------------------------------------
 
  ServerlessError: Export 'projectName-stageName-ServerlessAliasReference' does not exist.
      at /var/jenkins/workspace/projectName/node_modules/serverless/lib/plugins/aws/provider.js:1406:27
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

Abhijith-Nagaraja avatar Feb 04 '21 17:02 Abhijith-Nagaraja

Unfortunately I cannot help with it.

Enase avatar Feb 04 '21 19:02 Enase

@Enase: Created a PR for this https://github.com/serverless-heaven/serverless-aws-alias/pull/201 by looking at your serverless-aws-alias-fixed and it works. I am able to create alias successfully. I don't know why your PR is pending in such long time and it is little out of date in terms of dependencies.

So hopefully this can get merged quickly so that we can drop our patch works

Abhijith-Nagaraja avatar Feb 05 '21 21:02 Abhijith-Nagaraja

@Abhijith-Nagaraja repository owner doesn't replay more then a year. I've created serverless-aws-alias-fixed by request of community members.

PS: I don't think that it's a good choice to use this plugin if you start a new project. Consider to use stages without aliases.

Enase avatar Feb 05 '21 21:02 Enase

@Enase Awesome, checking that out now. 👍👍👍

clarkritchie avatar Feb 12 '21 20:02 clarkritchie

remove - serverless-aws-alias plugin and dont install that plugin.

It looks like the newer versions of serverless don't require you to use that to define stages. I tried it and it fixed the problem.

amanbedi23 avatar Mar 19 '21 06:03 amanbedi23

Those are still struggling to get this working in 2021:

I found alternative solution

I used this plugin: https://github.com/davidgf/serverless-plugin-canary-deployments

and use this in your yml file

plugins:
  - serverless-plugin-canary-deployments
  
functions:
  hello:
    handler: handler.hello
    events:
      - http: GET hello
    deploymentSettings:
      type: AllAtOnce
      alias: sampleAlias

kunalfleethawks avatar Jun 09 '21 05:06 kunalfleethawks

I'm also encountering this issue.

chandywerks avatar Sep 13 '21 17:09 chandywerks

  • serverless-plugin-canary-deployments

This works but it will throw log group alias already exist error when deploying to existing stage with same alias. Like if you have deployed it on all the following stages: dev, stg, prd and you are again deploying a change on dev.

muqadar-ali avatar Nov 04 '21 04:11 muqadar-ali