serverless / serverless-client-s3

A plugin to deploy front-end assets to S3 via the Serverless Framework
http://www.serverless.com
171 stars 61 forks source link

Deploy - invalid bucket name #9

Closed karlsburg closed 8 years ago

karlsburg commented 8 years ago

Error when deploying:

sls client deploy

Serverless: Deploying client to stage "dev" in region "eu-west-1"...
Serverless: / /usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:49
        fn = function () { throw arg; };
                           ^

InvalidBucketName: The specified bucket is not valid.
    at Request.extractError (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/services/s3.js:328:35)
    at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:596:14)
    at Request.transition (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:21:10)
    at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:37:9)
    at Request.<anonymous> (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:598:12)
    at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:596:14)
    at Request.transition (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:21:10)
    at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:37:9)
    at Request.<anonymous> (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:598:12)
    at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at callNextListener (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
    at IncomingMessage.onEnd (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/event_listeners.js:209:11)
    at emitNone (events.js:85:20)
    at IncomingMessage.emit (events.js:179:7)
From previous event:
    at ServerlessProviderAws.request (/usr/local/lib/node_modules/serverless/lib/ProviderAws.js:65:14)
    at ClientDeploy.<anonymous> (/Users/user/Projects/reasonauth_core/node_modules/serverless-client-s3/index.js:191:28)
From previous event:
    at ClientDeploy._processDeployment (/Users/user/Projects/reasonauth_core/node_modules/serverless-client-s3/index.js:181:10)
From previous event:
    at ClientDeploy.clientDeploy (/Users/user/Projects/reasonauth_core/node_modules/serverless-client-s3/index.js:50:10)
From previous event:
    at /usr/local/lib/node_modules/serverless/lib/Serverless.js:181:31
    at Array.reduce (native)
    at /usr/local/lib/node_modules/serverless/lib/Serverless.js:180:32
From previous event:
    at Serverless._execute (/usr/local/lib/node_modules/serverless/lib/Serverless.js:178:12)
    at Serverless.actions.(anonymous function) (/usr/local/lib/node_modules/serverless/lib/Serverless.js:424:20)
    at Serverless.command (/usr/local/lib/node_modules/serverless/lib/Serverless.js:393:38)
    at /usr/local/lib/node_modules/serverless/bin/serverless:19:16
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at Object.<anonymous> (/usr/local/lib/node_modules/serverless/bin/serverless:18:4)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:139:18)
    at node.js:999:3
eahefnawy commented 8 years ago

@karlsburg what's the name of your project?

karlsburg commented 8 years ago

ReasonAuthCore. It's not a public repo, will open it up if you want to have a look?

eahefnawy commented 8 years ago

@karlsburg no need. I see where the issue is. We set the website bucket name with this format: <projectName>.client.<stage>.<region> ... and bucket names can't contain capital letters (From AWS: Bucket names can contain lowercase letters, numbers, and hyphens. Each label must start and end with a lowercase letter or a number.). This is not your fault of course since we can't expect you to change your project name.

I'm gonna change this behavior and instead let users specify the bucket name in s-project.json like this:

"client": {
    "bucket": "client_BUCKET_NAME"
  }

Thanks for reporting this, and stay tuned! ;)

karlsburg commented 8 years ago

@eahefnawy - brilliant, thanks for the quick response, and great work on the serverless projects.

While you're at it a path attribute would be handy also as mentioned in #10.

"client": {
    "bucket": "client_BUCKET_NAME"
    "path": "client/www"
  }
duckworth commented 8 years ago

I like the suggested option to specify a bucket, but might it also make sense to lowercase the the existing format as well so it will work with no changes?

eahefnawy commented 8 years ago

@duckworth it goes beyond this issue. It was a mistake from my side to set a default bucket name because I realized that in enterprise environments, some teams don't have control over the company bucket naming policies, so the bucket name should follow a certain company policy. Because of that we want to give the user complete control over what the bucket name should be.

I hope that makes sense :)

eahefnawy commented 8 years ago

Although, one disadvantage is that there's the extra step of having to specify a bucket name before using the plugin...hmmm....

karlsburg commented 8 years ago

A nice way around that would be to allow user to specify bucket name in config, but if it's not specified, fall back to your original naming convertion (in lowercase ;)

eahefnawy commented 8 years ago

Done! Just released to npm as well. Let me know if you face any other issues @karlsburg :blush:

karlsburg commented 8 years ago

Great - Thank you @eahefnawy :+1: