Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the stage option through CLI is not applied #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rodumani
Copy link

@rodumani rodumani commented Jun 22, 2022

Hello, I'm Charles and I'm glad that I can contribute to the awesome plugin. If I have missed some guidelines to contribute, please feel free to know to reissue the PR.

I have found an issue that the plugin is not respecting the --stage CLI option.

When I have two stages: staging and prod with different distributionIDs, I thought the following config and the command should work.

serverless.yml

provider:
  name: aws
  runtime: nodejs14.x
  region: us-east-1
  stage: staging

custom:
  lambdaEdgePreExistingCloudFront:
    validStages:
      - staging
      - prod

functions:
  origin-request:
    handler: src/origin-request/index.handler
    memorySize: 128
    timeout: 30
    role: lambdaRole
    events:
      - preExistingCloudFront:
          distributionId: PRODDISTID
          eventType: origin-request
          pathPattern: '*'
          includeBody: true
          stage: prod
      - preExistingCloudFront:
          distributionId: STAGINGDISTID
          eventType: origin-request
          pathPattern: '*'
          includeBody: true
          stage: staging
...
$ serverless deploy --stage prod

However, because it's using a stage variable inside the provider which is a default stage value, not the current stage that serverless is deploying, it is not working as expected.

The serverless has deployed the lambda function to the prod environment but the plugin is updating the staging environment even if the stage option has been set as 'prod'.

This simple PR is fixing the above issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant