This is a glossary of all the common issues in Serverless-Serverless
  • 08-Jan-2023
Lightrun Team
Author Lightrun Team
Share
This is a glossary of all the common issues in Serverless-Serverless

Troubleshooting Common Issues in Serverless-Serverless

Lightrun Team
Lightrun Team
08-Jan-2023

Project Description

 

The Serverless Framework is an open-source tool that allows developers to build, deploy, and manage Serverless applications and infrastructure. It provides a simple, powerful, and flexible way to build and deploy Serverless applications using a variety of cloud providers, including AWS, Azure, Google Cloud, and more.

The Serverless Framework consists of a command-line interface (CLI) and a set of libraries and plugins that help developers build and deploy Serverless applications. It provides a simple, declarative syntax for defining Serverless functions, events, and resources, and automates the process of deploying and managing these resources on the cloud provider.

Using the Serverless Framework, developers can build Serverless applications using a variety of programming languages, including Node.js, Python, Java, and more. It also provides integrations with popular tools and services, such as AWS Lambda, Amazon API Gateway, DynamoDB, and more, making it easy to build and deploy complex Serverless applications and infrastructure.

 

Troubleshooting Serverless-Serverless with the Lightrun Developer Observability Platform

 

Getting a sense of what’s actually happening inside a live application is a frustrating experience, one that relies mostly on querying and observing whatever logs were written during development.
Lightrun is a Developer Observability Platform, allowing developers to add telemetry to live applications in real-time, on-demand, and right from the IDE.
  • Instantly add logs to, set metrics in, and take snapshots of live applications
  • Insights delivered straight to your IDE or CLI
  • Works where you do: dev, QA, staging, CI/CD, and production

The most common issues for Serverless-Serverless are:

 

Mixed Content: The page was loaded over HTTPS, but requested an insecure resource

 

Mixed content errors occur when a webpage that is loaded over HTTPS requests resources from an HTTP server. This can be a problem because it can compromise the security of the webpage, since the HTTP resources can be manipulated by attackers.

To fix this error, you need to make sure that all resources on your webpage are loaded over HTTPS. This includes all images, scripts, and stylesheets.

One way to do this is to use relative URLs for all resources on your webpage. This way, the browser will request the resources using the same protocol as the webpage.

For example, instead of using an absolute URL like “http://example.com/image.jpg”, you would use a relative URL like “/image.jpg”.

If you are using the Serverless Framework to deploy your webpage, you can set the stage: production variable in your serverless.yml file. This will automatically convert all of your URLs to HTTPS when you deploy your application.

For more information on mixed content errors and how to fix them, you can refer to the following resources:

 

Doesn’t include declaration file (.d.ts) while compilation

 

There are a few possible reasons for this:

  1. You may not have the "declaration" option set to true in your tsconfig.json file. This option tells the TypeScript compiler to generate declaration files for your project.
{
  "compilerOptions": {
    "declaration": true,
    ...
  }
}
  1. You may not have the "include" option set to include the declaration files in your tsconfig.json file.
{
  "include": [
    "**/*.ts",
    "**/*.d.ts"
  ],
  ...
}
  1. The declaration files may not be located in the same directory as the TypeScript source files. By default, the TypeScript compiler looks for declaration files in the same directory as the source files. If your declaration files are located elsewhere, you will need to specify their location using the "typeRoots" option in your tsconfig.json file.
{
  "compilerOptions": {
    "typeRoots": [
      "node_modules/@types",
      "custom_typings"
    ],
    ...
  }
}

 

Multiple Lambda functions from the sam.yml file possible?

 

Yes, it is possible to define multiple Lambda functions in a single serverless.yml file using the Serverless Framework.

Here is an example of how you might define multiple functions in your serverless.yml file:

functions:
  firstFunction:
    handler: first.handler
    events:
      - http:
          path: /first
          method: get
  secondFunction:
    handler: second.handler
    events:
      - http:
          path: /second
          method: get

In this example, we have defined two functions: firstFunction and secondFunction. Each function has an associated event that triggers the function, in this case an HTTP GET request to a specific path.

You can also specify additional configuration options for each function, such as the runtime, memory size, and timeout.

For more information on defining functions in the Serverless Framework, you can refer to the Functions documentation.

 

The CloudFormation template is invalid: S3 error: The specified bucket does not exist

 

There are a few possible reasons for this error:

  1. You may have typed the name of the S3 bucket incorrectly in your serverless.yml file. Double-check the spelling and case of the bucket name to make sure it is correct.
  2. You may not have created the S3 bucket yet. The Serverless Framework does not automatically create S3 buckets for you, so you will need to create the bucket yourself before deploying your application.
  3. You may have deleted the S3 bucket after you last deployed your application. The CloudFormation stack that is created by the Serverless Framework references the S3 bucket, so if you delete the bucket, the stack will become invalid.

To fix this error, you will need to either create the S3 bucket or update the CloudFormation stack to reference an existing S3 bucket.

For more information on using S3 with the Serverless Framework, you can refer to the AWS documentation and the Serverless Framework documentation.

 

“The access token is from the wrong issuer” error

 

This error can occur if you are using an OAuth 2.0 provider (such as Auth0 or Okta) to authenticate your users, and the issuer of the access token (the authorization server) does not match the expected issuer.

There are a few possible causes of this error:

  1. You may have configured the Serverless Framework to expect a different issuer than the one that issued the access token. Make sure that the issuer in your Serverless Framework configuration matches the issuer of the access token.
  2. You may have multiple authorization servers issuing access tokens for the same client. If this is the case, you will need to configure the Serverless Framework to accept tokens from multiple issuers.
  3. The access token may have been tampered with or forged. Make sure that you are properly validating the access token and verifying its signature to ensure it is legitimate.

To fix this error, you will need to identify the root cause and update your configuration or validation logic accordingly.

For more information on using OAuth 2.0 with the Serverless Framework, you can refer to the Serverless Framework documentation.

 

Setting existing:true on S3 bucket causes deployment to fail

 

The existing: true option tells the Serverless Framework to use an existing S3 bucket instead of creating a new one. This can be useful if you have an existing bucket that you want to use for your application.

However, if you are using the existing: true option and the specified S3 bucket does not exist, the deployment will fail. This is because the Serverless Framework is unable to find the bucket and will not be able to deploy your application.

To fix this error, make sure that the S3 bucket specified in the serverless.yml file exists and that you have the correct permissions to access it.

You can also try removing the existing: true option and allowing the Serverless Framework to create a new S3 bucket for your application.

For more information on using S3 with the Serverless Framework, you can refer to the AWS documentation and the Serverless Framework documentation.

Share

It’s Really not that Complicated.

You can actually understand what’s going on inside your live applications.

Try Lightrun’s Playground

Lets Talk!

Looking for more information about Lightrun and debugging?
We’d love to hear from you!
Drop us a line and we’ll get back to you shortly.

By submitting this form, I agree to Lightrun’s Privacy Policy and Terms of Use.