Cannot use --stage or change stage manually when deploying CDN component
Bug Report
Description
- What did you do?
I created a serverless project using the CDN component. When I run serverless, everything is deployed just fine and uses the default dev stage value.
I then try to deploy to staging by running serverless deploy --stage staging.
- What happened?
I'm getting Error: "component" input is required to run custom methods.
If I run SERVERLESS_STAGE=staging serverless it deploys but to the default stage of dev.
If I change my hardcoded stage to staging and run serverless I get the error IllegalUpdate: The 'originPath' field is missing., full output included below.
Interestingly, the s3 bucket for staging gets created, but the cloudfront distribution does not. Also, the s3 bucket for the dev stage looks like it's removed and the staging bucket created. When I run serverless again with the dev stage, the dev s3 bucket is back and the deploy succeeds.
- What should've happened?
I should be able to deploy using the stage flag, and barring use the SERVERLESS_STAGE env var, and barring that by manually changing changing the hardcoded stage.
- What's the content of your
serverless.ymlfile?
name: customdomain-com-cdn
stage: dev
CDN:
component: '@serverless/cdn'
inputs:
region: us-west-2
domain: ${custom.${stage}.subdomain}.customdomain.com
bucketName: customdomain-com-cdn-${stage}
custom:
dev:
subdomain: cdn-${stage}
staging:
subdomain: cdn-${stage}
prod:
subdomain: cdn
- What's the output you get when you use the
SLS_DEBUG=*environment variable (e.g.SLS_DEBUG=* serverless deploy)
After I deploy to the default stage of dev and then change stage to staging and run serverless:
error:
{ IllegalUpdate: The 'originPath' field is missing.
at Request.extractError (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/protocol/rest_xml.js:53:29)
at Request.callListeners (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/jshumate/.serverless/components/registry/npm/@serverless/[email protected]/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
message: 'The \'originPath\' field is missing.',
code: 'IllegalUpdate',
time: 2020-05-04T09:44:40.585Z,
requestId: 'acffc188-af51-4a12-9835-f4b0dc6253fa',
statusCode: 400,
retryable: false,
retryDelay: 7.354804063429676 }