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

Layers deployment bucket does not exist #2

Open
eduardo3g opened this issue Sep 23, 2021 · 3 comments
Open

Layers deployment bucket does not exist #2

eduardo3g opened this issue Sep 23, 2021 · 3 comments

Comments

@eduardo3g
Copy link
Owner

The error below is thrown when the command npx sls deploy is executed. This comes from the serverless-layers plugin because it could not find an S3 Bucket to push the layers during the deployment.

image

@eduardo3g eduardo3g mentioned this issue Sep 23, 2021
@eduardo3g
Copy link
Owner Author

This error occurs because, during the deployment with Serverless Framework, it goes to SSM Parameter Store to retrieve an S3 bucket name - which is the bucket that'll store the dependencies files, etc.

There are currently three approaches to deploy the back-end application:

Easiest way - Removing Serverless Layers feature

  1. Open serverless.yml file.
  2. Comment lines 8, 28 and 29.
  3. Run the command npx sls deploy.

Manually creating an S3 Bucket for your layers and SSM Parameter

  1. Open S3 and create a bucket following the pattern twitterappsync-layer-deployment-bucket-<an-unique-identifier>. Remember that S3 is a global service, so S3 bucket names must be unique.
  2. Save the S3 bucket name on your notes. For example, twitterappsync-layer-deployment-bucket-ASDKJL1d.
  3. Open AWS Systems Manager and select Parameter Store on the left menu
  4. Create a parameter named twitterappsync/dev/layer-deployment-bucket. The parameter type can be String.
  5. On the parameter value, copy the S3 bucket name you have in your notes.
  6. Once S3 and SSM is set up, deploy your app: npx sls deploy

The ideal solution

Unfortunately, there's not a workaround via Serverless Framework to first deploy an S3 Bucket and SSM Parameter, the deploy the app using serverless layers.

One good approach is combining Serverless Framework with some IaC (Infrastructure as Code) tool such as Terraform. I'd go with the following solution:

  1. Create a Terraform script using HCL, that'll create an S3 Bucket and an SSM Parameter.
  2. Builder a shell script to run both deployments commands: Terraform first and then Serverless Framework.
  3. Execute the shell script locally or on a CI/CD pipeline.

@pchauhan77
Copy link

pchauhan77 commented Sep 28, 2021

can you solve it and share running application and please share .env example ?
Please add terraform also if need

@eduardo3g
Copy link
Owner Author

Hi @pchauhan77, adding the Terraform step is on my roadmap but there is not an ETA yet.

I recommend you to follow the second option ("Manually creating an S3 Bucket for your layers and SSM Parameter") for now.

Regarding the .env file, there's already a closed issue for that. After you're able to deploy the application by running npx sls deploy, run the command npm run exportEnv and it'll generate a .env file in your root directory.

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

2 participants