@serverless/sf
N/A
Last updated 4 months ago by serverless-main .
MIT · Original npm · Tarball · package.json
$ cnpm install @serverless/sf 
SYNC missed versions from official npm registry.

Serverless Framework V.2

 

"The future of cloud is outcomes, not infrastructure."

 

 

Get Started

Clone repo.

$ git clone https://github.com/serverless/v2.git

Install dependencies.

cd v2 && npm i -g

Pick an example. Each example requires credentials for Amazon Web Services set as environment variables.

Serverless Framework V.2 supports .env files in the same folder as serverless.yml or serverless.js. Create one that looks like this:

AWS_ACCESS_KEY_ID=123456789
AWS_SECRET_ACCESS_KEY=987654321

Run $ v2.

$ website: v2
  
  ✔  my-site

     URL  http://serverless-6vql3jp9.s3-website-us-east-1.amazonaws.com

  3s › dev › my-site › Done

You can leverage different environment variables for different stages by using this naming convention:

.env # Default
.env.dev
.env.prod

How To Use A Serverless Component Programmatically

Create a new javascript file, and load/use Components like this:


// To load a Component, instantiate it's class...
const realtimeApp = new RealtimeApp('instanceId', { /* inputs */ })

// To run/deploy/update a Component, call it's default function...
await realtimeApp()

// To run extra functionality, use custom methods that come w/ the Component...
await realtimeApp.loadTest()

How To Use A Serverless Component Declaratively

Use a serverless.yml file, like this:


name: realtimeApp
stage: dev

providers:
  AwsProvider::aws:
    accessKeyId: ${secrets:aws_access_key_id}
    secretAccessKey: ${secrets:secret_access_key}

components:
  RealtimeApp::realtimeApp:
    name: ${name}-${stage}
    code: ./src/backend

Then use your CLI, like this:

# To run/deploy/update all Components, call 'serverless'...
$ serverless

# To run extra functionality that comes with the a component, call this...
$ serverless loadTest myRealtimeApp

# To remove Components in YAML, call this...
$ serverless remove

How To Write A Serverless Component

Use a serverless.js file, like this:


class MyComponent extends Component {

  /*
  * Default (Required)
  * - The default functionality to run/provision/update your Component
  */

  async default() { }

  /*
  * Remove (Optional)
  * - If your Component removes infrastructure, this is recommended.
  */

  async remove() { }
}

Created By

  • Eslam Hefnawy - @eahefnawy
  • Philipp Muens - @pmmuens

Current Tags

  • 0.0.6                                ...           latest (4 months ago)

5 Versions

  • 0.0.6                                ...           4 months ago
  • 0.0.5                                ...           4 months ago
  • 0.0.4                                ...           4 months ago
  • 0.0.3                                ...           4 months ago
  • 0.0.2                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 5
Dependencies (16)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |