components icon indicating copy to clipboard operation
components copied to clipboard

How can I specify S3 bucket ?

Open ahmad-crossplatform opened this issue 4 years ago • 9 comments

Description

Hello I am new to this , and I am using the website template to deploy to S3 . The problem is that in my build server (using github actions) it creates almost a different bucket on each deploy , how can I specify which bucket I want to deploy to ?

Additional Data

E.g. stack trace, version, operating system, ...

ahmad-crossplatform avatar Apr 27 '20 10:04 ahmad-crossplatform

@ahmad-crossplatform That doesn't sound right. how does your yaml look like?

eahefnawy avatar Apr 27 '20 15:04 eahefnawy

name: website

website:
  component: "@serverless/website"
  inputs:
    code:
      src: build
      hook: npm run build
    domain: beta.crossplatform.se

ahmad-crossplatform avatar Apr 29 '20 15:04 ahmad-crossplatform

ah yeah, you are still using V1 of the website component, which does not work in CI/CD. Please use V2 instead. It's a lot faster and more stable: https://github.com/serverless-components/website

eahefnawy avatar Apr 30 '20 12:04 eahefnawy

@eahefnawy thanks , but just to be clear , the difference between V1 and V2 is just the configuration right ? as long as i have the latest serverless cli .

ahmad-crossplatform avatar May 07 '20 12:05 ahmad-crossplatform

the implementation of each component is also different. So for a component that was deployed with v1 will likely break when deployed with v2.

If possible, I suggest that you remove your v1 component, change the config to be v2 compatible then deploy again. Hopefully, that would reduce the conflict risk

eahefnawy avatar May 07 '20 12:05 eahefnawy

@eahefnawy when I tried the new config

component: website # (required) name of the component. In that case, it's website.
name: crossplatform-website # (required) name of your website component instance.
org: serverlessinc # (optional) serverless dashboard org. default is the first org you created during signup.                   # (optional) serverless dashboard app. default is the same as the name property.
stage: dev # (optional) serverless dashboard stage. default is dev.

inputs:
  src: ./src # (optional) path to the source folder. default is a hello world html file.
  domain: beta.crossplatform.se # (optional) domain name. this could also be a subdomain.
  region: eu-north-1 # (optional) aws region to deploy to. default is us-east-1.
  bucketName: beta.crossplatform.se # (optional) aws bucket name. default is an auto generated name.

I got an error


 Error: 401 - Your credentials do not have access to t
he Organization with the name of: serverlessinc.  Try logging into a different account.

while the old configuration worked fine . have i done something wrong ?

ahmad-crossplatform avatar May 07 '20 16:05 ahmad-crossplatform

Nothing here?

ahmad-crossplatform avatar May 18 '20 11:05 ahmad-crossplatform

@ahmad-crossplatform please remove the org property from the yaml file. It's there to serve as a complete example for when you want to deploy to one of your own specific orgs, but it seems that it causes confusion. Sorry about that 😊

eahefnawy avatar May 25 '20 09:05 eahefnawy

@eahefnawy
Hello I Just noticed that you responded to my message . I have tried to remove the "Org" property and got the following error

Error: AWS credentials not found. Make sure you have a .env file in the cwd. - Docs: https://git.io/JvArp
    at getClients (/var/task/utils.js:24:11)
    at Website.deploy (/var/task/serverless.js:26:21)
    at Runtime.module.exports [as handler] (/opt/nodejs/node_modules/@serverless/core/handler.js:273:53)

when I checked the link mentioned and got this info

Note: For AWS, if no .env file was found in the current working directory or immediate parent directory, the CLI will attempt to get the credentials from AWS's shared credentials file (typically at ~/.aws/credentials) as a fallback according to your AWS_DEFAULT_PROFILE or AWS_PROFILE environment variables, just like how it works on the AWS SDK.

Note that it worked without problems in older template (besides the S3 bucket name)

ahmad-crossplatform avatar Jun 01 '20 14:06 ahmad-crossplatform