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

The specified bucket is not valid. #98

Open
tvb opened this issue Jan 11, 2018 · 6 comments
Open

The specified bucket is not valid. #98

tvb opened this issue Jan 11, 2018 · 6 comments

Comments

@tvb
Copy link

tvb commented Jan 11, 2018

Its seems I cannot run serverless remove --stage prod. I am sure the correct bucket has been exported:

Serverless: Could not remove AWS package storage: The specified bucket is not valid.

  Invalid Bucket Name ------------------------------------

  The specified bucket is not valid.

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           8.1.4
     Serverless Version:     1.25.0
@tvb
Copy link
Author

tvb commented Jan 11, 2018

And same for applying a custom domain name:

$ serverless codebox domain --stage staging  --host mydomainname.com
Serverless: Load command run
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command emit
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: WARNING: Plugin EnvironmentVariablesCheck uses deprecated hook before:deploy:initialize,
                     use package:initialize hook instead
Serverless: Load command webpack
Serverless: Load command webpack:invoke
Serverless: Load command webpack:watch
Serverless: Load command webpack:serve
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook before:deploy:createDeploymentArtifacts,
                     use package:createDeploymentArtifacts hook instead
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook after:deploy:createDeploymentArtifacts,
                     use package:createDeploymentArtifacts hook instead
Serverless: Load command codebox
Serverless: Load command codebox:domain
Serverless: Load command codebox:encrypt
Serverless: Load command codebox:index

 Serverless Warning --------------------------------------

  A valid environment variable to satisfy the declaration 'env:CODEBOX_RESTRICTED_ORGS' could not be found.


 Serverless Warning --------------------------------------

  A valid environment variable to satisfy the declaration 'env:CODEBOX_INSIGHTS_CLIENT_ID' could not be found.


 Serverless Warning --------------------------------------

  A valid environment variable to satisfy the declaration 'env:CODEBOX_INSIGHTS_SECRET' could not be found.

Serverless: Invoke codebox:domain
Serverless: Domain update failed for mydomainname.com
Serverless: The specified bucket is not valid.

@tvb tvb changed the title Could not remove AWS package storage: The specified bucket is not valid. The specified bucket is not valid. Jan 11, 2018
@Tellan
Copy link

Tellan commented Jan 13, 2018

It seems to be the way the bucket is referenced in the codebox-tools. See these lines:

this.bucket = this.serverless.service.resources
.Resources
.PackageStorage
.Properties
.BucketName;

They are returning ${self:provider.environment.bucket} which is what is actually specified in the serverless.yml.

It seems serverless only has these values populated inside the handlers, so each handler should look it up itself, instead of doing it in the constructor. Like so:

  migrate() {
    this.bucket = this.serverless.service.resources
      .Resources
      .PackageStorage
      .Properties
      .BucketName;

Making this change in the migrate function has it working, but I'm now getting Access Denied errors, which are probably on my end.

@israphim
Copy link

Access Denied seems to be related to missing Encryption on the S3-Put

@mcroker
Copy link

mcroker commented May 12, 2018

I was having exactly the same issue with host migration....

$ serverless codebox domain --stage prod --host npm.mydomain.com
...
Serverless: Domain update failed for npm.mydomain.com
Serverless: The specified bucket is not valid.

A bit of an ugly workaround (OK a very ugly workaround) but... temporarily hard-coding the bucket into serverless.yaml worked for me...

resources:
  Resources:
    PackageStorage:
      Type: AWS::S3::Bucket
      Properties:
        AccessControl: Private
        BucketName: "npm.mydomain.com-prod"
        # ORIGIAL CODE --- BucketName: ${self:provider.environment.bucket}

@thomastoye
Copy link

thomastoye commented Jul 16, 2018

Any update on this? I set up a custom domain in API gateway, but when I run serverless codebox domain --stage prod --host xxxx I get

Serverless: Domain update failed for xxxx
Serverless: The specified bucket is not valid.

Hard-coding the bucket the BucketName, as @mcroker suggests, yields me

Serverless: Domain update failed for xxxx
Serverless: Access Denied

SLS_DEBUG=* gives me no extra information:

[cut off]
Serverless: Load command webpack:serve
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook before:deploy:createDeploymentArtifacts,
                     use package:createDeploymentArtifacts hook instead
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook after:deploy:createDeploymentArtifacts,
                     use package:createDeploymentArtifacts hook instead
Serverless: Load command codebox
Serverless: Load command codebox:domain
Serverless: Load command codebox:encrypt
Serverless: Load command codebox:index
Serverless: Invoke codebox:domain
Serverless: Domain update failed for xxxx
Serverless: Access Denied

@kersten
Copy link

kersten commented Nov 13, 2018

@thomastoye to fix this issue just add ServerSideEncryption: 'AES256' to the migrate() function in the putObject call.

putPromises.push(
          this.s3.putObject({
            Bucket: this.bucket,
            Key: newItem.key,
            Body: JSON.stringify(json),
            ServerSideEncryption: 'AES256',
          }).promise() )

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

No branches or pull requests

6 participants