Webiny- The easiest way to adopt serverless

Garima Singh
5 min readJan 8, 2021

What is Webiny?

Webiny is an open-source framework for building serverless applications. It provides you with developer tools, libraries, ready-made apps and processes. It’s built on top of AWS cloud and uses the latest technologies such as NodeJs, React and GraphQL.

It’s designed for building websites, apps and APIs that scale to millions of users and run on top of serverless infrastructure like AWS Lambda.

Photo by Cookie the Pom on Unsplash

Features

GraphQL API layer you can expand

Create new GraphQL schemas, register new microservices and let the built-in Apollo Federation connect it all together. Webiny includes security utilities so you can easily control who can access what. Each microservice runs in its own function and is ready to scale when you need it the most.

Unified GraphQL schema with Apollo Gateway

Each microservice you create registers its queries and mutations with the central Apollo Gateway and exposes a unified GraphQL schema to the rest of the system. Our scaffolding templates make it quick and easy to create new services and expand your schema.

Secured out of the box

Security is a crucial layer in any application. Webiny includes a customizable security module you can use in your schemas. There is also a built-in UI to manage users, groups, roles and scopes.

Create and deploy projects with a single command

Use the Webiny CLI to bootstrap a project and deploy it to a serverless cloud within minutes. The CLI creates all the required resources like AWS Lambdas, S3, API Gateway, CDN and connects them together.

Use scaffolding templates to expand your project

You can read through several pages on how to create a new microservice, or you can just run the `webiny scaffold` command which will create one for you in seconds and hook it up with the rest of the system. Once created you can add your business logic to it and deploy it to your cloud.

Control your deploy process

Webiny CLI comes with hooks as integration points. You can use these hooks to further expand the deploy process, like adding CI/CD support and syncing state files. The CLI is also pluginable, so you can build new functionality to optimise your development and deployment process even further.

Photo by Paul Hanaoka on Unsplash

Quick Start

This is a quick start guide that should help you setup Webiny as fast as possible.

At the end of this guide, you’ll have a simple website, that already comes with a couple of default pages to get you started, and a complete admin interface that will enable you to manage it. All of this will be deployed to the AWS Cloud.

Prerequisites

The following things are mandatory for both local development and production deployments:

✅ node.js >= 12.0.0

  • earlier node versions may also work but we don’t test them regularly
  • we recommend this tool to manage your node.js versions

yarn < 2.0

✅ AWS account with an IAM user for programmatic usage

✅ MongoDB database in the cloud

NOTE: if you’re unsure your AWS credentials are configured correctly, you can verify them by running the following command using AWS CLI: aws sts get-caller-identity. If you don't see the user info, take a look at this tutorial to create an IAM user for programmatic usage.

Photo by Brooke Cagle on Unsplash

1. Create a new project

To create a Webiny project:

npx create-webiny-project new-project

2. Setup database connection

Edit .env.json file in the root of the project and set the MONGODB_SERVER value. The values in this file are unique for your project, you do NOT need to change any other values.

In case you need any help creating a MongoDB cluster on MongoDB Atlas, please follow this guide.

IMPORTANT: It’s important to give the outside world access to your database because the database will be accessed from your cloud functions, thus you’ll never have a fixed IP address. See the Whitelist Your Connection IP Address. Make sure you add a 0.0.0.0/0 entry.

Your .env.json file should look something like this after updating your MONGODB_SERVER and MONGODB_NAME parameters:

{

“default”: {

“AWS_PROFILE”: “default”,

“AWS_REGION”: “us-east-1”,

“MONGODB_SERVER”: “mongodb+srv://{YOUR_USERNAME}:{YOUR_PASSWORD}@someclustername.mongodb.net”,

“MONGODB_NAME”: “{YOUR_MONGODB_NAME}”,

“DEBUG”: true

}

}

NOTE: AWS_PROFILE as well as AWS_REGION can be defined by other methods following this guide. As long as AWS SDK can figure out your identity, Webiny will be happy no matter how you configure your credentials.

3. Project runtime

1. Deploy API

We need to deploy a local API environment to use for local development:

yarn webiny deploy api — env=local

In the command above, api references the folder containing deployment configuration, which is located in api/resources.js. As a result, you can create additional folders like api-private, api-public, etc... as long as they have a resources.js file inside.

The deployment will take around 5 to 15 minutes depending on your internet connection and the AWS region.

NOTE: If you run into an error: CredentialsError: Missing credentials in config, it means you have to configure your provider credentials here. If you use multiple AWS profiles, edit .env.json in your project root, to point to the correct profile via AWS_PROFILE.

2. Start admin app

Admin app is the administration system for your project; it contains everything you need to manage your content, users, settings, etc… :

cd apps/admin

yarn start

Once started, admin app will run an installation wizard to setup the system.

IMPORTANT: Do NOT go onto the next step until you complete the installation wizard.

3. Start site app

Site app is an actual website you’re creating. It is a single page app, but in production it renders via server-side rendering.

cd apps/site

yarn start

This is it! You have deployed your own API environment, and can begin developing your React apps on your local machine.

Photo by Taylor Vick on Unsplash

References/Sources

  1. https://docs.webiny.com/docs/get-started/quickstart/
  2. https://www.webiny.com/features/

--

--