GithubHelp home page GithubHelp logo

goserverless's Introduction

Go Serverless

Build Status

GoFormation for users wishing to transfer to serverless!

GoFormation is a Go library for working with AWS CloudFormation / AWS Serverless Application Model (SAM) templates.

Main features

  • Describe Serverless templates as Go objects (structs), and then turn it into YAML.

Installation

As with other Go libraries, GoFormation can be installed with go get.

$ go get github.com/thepauleh/goserverless/serverless

Usage

Marshalling Serverless with Go structs, into YAML

Below is an example of building a CloudFormation template programmatically, then outputting the resulting JSON

package main

import (
	"fmt"

	"github.com/thepauleh/goserverless/serverless"
)

func main() {

	// Create a new CloudFormation template
    template := serverless.NewTemplate("myService")
    
    template.Service = "myService"

    template.Provider = &serverless.Provider{
        Name: "aws",
        Runtime: "nodejs6.10",
        MemorySize: 512,
        Timeout: 10,
        VersionFunctions: false
    }

	// An example function
	template.Functions["users"] = &serverless.AWSServerlessFunction{
		Handler: "service.o",
        Name:   "${self:provider.stage}-users",
        Description: "Description of what the lambda function does",
        Runtime: "go1.x",
        MemorySize: 128,
        ReservedConcurrency: 5,
        Timeout: 30,
		Events: []serverless.Events{
			serverless.HttpEvent{
				Path: "users/create",
				Method: "post",
			},
		},
	}

	y, err := template.YAML()
	if err != nil {
		fmt.Printf("Failed to generate YAML: %s\n", err)
	} else {
		fmt.Printf("%s\n", string(y))
	}
}

Would output the following YAML template:

service: myService

provider:
  name: aws
  runtime: nodejs6.10
  memorySize: 512
  timeout: 10
  versionFunctions: false

functions:
  users:
    handler: service.o 
    name: ${self:provider.stage}-users
    description: Description of what the lambda function does
    runtime: go1.x
    memorySize: 128
    timeout: 30
    reservedConcurrency: 5
    events:
      - http:
          path: users/create
          method: post

goserverless's People

Contributors

anonfunc avatar dwight-holman avatar jameswoolfenden avatar nimrodkor avatar paul-psdigital avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

goserverless's Issues

Needs a License

Currently, the allowed uses of this library are unclear.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.