serverless-heaven / serverless-aws-alias

Alias support for Serverless 1.x
MIT License
189 stars 68 forks source link

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

Open Abhijith-Nagaraja opened 3 years ago

Abhijith-Nagaraja commented 3 years ago

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?

Enase commented 3 years ago

what is the command you run?

Abhijith-Nagaraja commented 3 years ago

@Enase : sls deploy

Abhijith-Nagaraja commented 3 years ago

@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
Enase commented 3 years ago

Unfortunately I cannot help with it.

Abhijith-Nagaraja commented 3 years ago

@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

Enase commented 3 years ago

@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.

clarkritchie commented 3 years ago

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

amanbedi23 commented 3 years ago

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.

kunalfleethawks commented 3 years ago

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
chandywerks commented 3 years ago

I'm also encountering this issue.

muqadar-ali commented 3 years ago
  • 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.