website icon indicating copy to clipboard operation
website copied to clipboard

bucketName property is not honored, not working

Open kling-appfire opened this issue 6 years ago • 7 comments

Given the following website serverless.yml the bucket is named a random system assigned GUID name regardless of if the bucketName property is there or not. ` name: my.domain.com stage: local

website: component: '@serverless/website' inputs: code: src: client/dist hook: domain=my.domain.com npm run clean:build region: us-east-1 bucketName: local.my.domain.com-specialbucketname123 env: API_URL: https://my.domain.com STAGE: local

domain: my.domain.com

` Tried:

  • With/without quotes
  • deleting and re-creating buckets via S3 console
  • bucket with desired name was able to be created via console as well.

kling-appfire avatar Oct 15 '19 22:10 kling-appfire

Hi @kling-appfire ... the bucketName is a recent addition from this PR #3 ... It's already published, but I'm guessing that at the time it was published, you already had a bucket deployed and saved to state, so it keeps using that (this is the expected behavior for backward compatibility).

So if you'd like to have your bucket name set, you could do a remove then deploy again with the bucketName set. I think it should work then.

If it doesn't let me know, I'll keep this issue open for ya! 😊

eahefnawy avatar Oct 17 '19 17:10 eahefnawy

Got it working! Not quite sure how. There were several issue related to having a 'stale' .serverless folder. We've been switching between .env (profiles) and there are apparently some stored settings in .serverless that need to be cleared out related to bucketnames.

Replicate by running with one bucketName, then change the bucketName w/same .serverless and it will not create a new bucket.

kling-appfire avatar Oct 17 '19 19:10 kling-appfire

I am not able to set bucketName to be customized something like ${self:provider.stage}-mybucketname.

himasimplisafe avatar Nov 08 '19 21:11 himasimplisafe

I am still able to setup bucketName but I noted that if we use full domain name i.e. my-app.domain.com then we will have an error relate to CloudFront distribution.

BTW, I have written this post to describe how to use the serverless component to deploy multiple stages/environments. We are using in production and have no issue so far.

hoang-innomize avatar Nov 09 '19 03:11 hoang-innomize

Thank you for the post. In my case, I used serverless website component, which do not have provider as aws in serverless.yml, hence I can't use resources>Resources> Bucket etc and I am deploying using just serverless, not serverless deploy. I used serverless.yml, not serverless.js. Maybe I need to switch to serverless.js to customize bucket for different environments.

himasimplisafe avatar Nov 09 '19 18:11 himasimplisafe

I am on a similar situation. For some reason I can not understand it allways tries to generate the same:

{
  "region": "us-east-1",
  "privateZone": false,
  "domain": "danielo.es",
  "subdomains": [
    {
      "domain": "pento.danielo.es",
      "type": "awsS3Website",
      "s3BucketName": "pento"
    }
  ]
}

Subdomain is correct, but buketName is not, domain is not... Here is my sls file:

name: time-tracker
stage: dev

myWebsite:
  component: "@serverless/website"
  inputs:
    code:
      root: ./ 
      src: ./build 
      hook: yarn build
    region: eu-central-1 
    bucketName: pento.danielo.es 
    domain: pento.danielo.es

danielo515 avatar Jan 14 '20 16:01 danielo515

I am in a similar situation I am attempting to do:

name: hv-app
service: hv-app

website:
  component: "@serverless/website"
  inputs:
    code:
      src: dist
      hook: yarn build
    region: us-east-1
    bucketName: hv-app-${opt:stage, 'dev'} ## dev or prod
    # domain: "hv-app"

storybook:
  component: "@serverless/website"
  inputs:
    code:
      src: storybook-static
      hook: yarn build-storybook
    region: us-east-1
    bucketName: hv-app-storybook-${opt:stage, 'dev'} ## dev or prod
    # domain: "hv-app-storybook"

theskillwithin avatar Dec 19 '20 02:12 theskillwithin