website
website copied to clipboard
bucketName property is not honored, not working
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.
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! 😊
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.
I am not able to set bucketName to be customized something like ${self:provider.stage}-mybucketname.
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.
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.
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
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"