Made some changes in file names and added zip files for deploying
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
build:
|
|
||||||
go get github.com/aws/aws-lambda-go/lambda
|
|
||||||
go get github.com/aws/aws-lambda-go/events
|
|
||||||
env GOOS=linux go build -ldflags="-s -w" -o bin/GO_API GO_API/server.go
|
|
||||||
zip deployment.zip bin/GO_API
|
|
||||||
2
backend/amazon/Task_API_service/.gitignore
vendored
Normal file
2
backend/amazon/Task_API_service/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Serverless directories
|
||||||
|
.serverless
|
||||||
6
backend/amazon/Task_API_service/Makefile
Normal file
6
backend/amazon/Task_API_service/Makefile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
build:
|
||||||
|
go get github.com/aws/aws-lambda-go/lambda
|
||||||
|
go get github.com/aws/aws-lambda-go/events
|
||||||
|
set GOOS=linux
|
||||||
|
go build -o bin/Task_API Tasks.go
|
||||||
|
C:\Users\Emir\go\bin\build-lambda-zip.exe -o bin/Task_API.zip bin/Task_API
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/labstack/echo"
|
|
||||||
"github.com/labstack/echo/middleware"
|
|
||||||
"github.com/aws/aws-lambda-go/events"
|
"github.com/aws/aws-lambda-go/events"
|
||||||
"github.com/aws/aws-lambda-go/lambda"
|
"github.com/aws/aws-lambda-go/lambda"
|
||||||
)
|
)
|
||||||
@@ -35,67 +32,17 @@ type Task struct {
|
|||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// This part was used just for testing if the application works correctly
|
|
||||||
/*
|
|
||||||
e := echo.New()
|
|
||||||
|
|
||||||
// Middleware
|
|
||||||
e.Use(middleware.Logger())
|
|
||||||
e.Use(middleware.Recover())
|
|
||||||
|
|
||||||
// CORS
|
|
||||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
|
||||||
AllowOrigins: []string{"*"},
|
|
||||||
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE},
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Getting JSON as []byte
|
|
||||||
b, err := convertTasksToJSON()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route => handler
|
|
||||||
e.GET("/tasks", func(c echo.Context) error {
|
|
||||||
return c.String(http.StatusOK, string(b[:]))
|
|
||||||
})
|
|
||||||
|
|
||||||
// Server
|
|
||||||
e.Start(":1500")
|
|
||||||
*/
|
|
||||||
|
|
||||||
lambda.Start(Handler)
|
lambda.Start(Handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Handler() (events.APIGatewayProxyResponse, error) {
|
func Handler() (events.APIGatewayProxyResponse, error) {
|
||||||
e := echo.New()
|
|
||||||
|
|
||||||
// Middleware
|
|
||||||
e.Use(middleware.Logger())
|
|
||||||
e.Use(middleware.Recover())
|
|
||||||
|
|
||||||
// CORS
|
|
||||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
|
||||||
AllowOrigins: []string{"*"},
|
|
||||||
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE},
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Getting JSON as []byte
|
// Getting JSON as []byte
|
||||||
b, err := convertTasksToJSON()
|
b, err := convertTasksToJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("error:", err)
|
fmt.Println("error:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route => handler
|
return events.APIGatewayProxyResponse {
|
||||||
e.GET("/", func(c echo.Context) error {
|
|
||||||
return c.String(http.StatusOK, string(b[:]))
|
|
||||||
})
|
|
||||||
|
|
||||||
// Server
|
|
||||||
e.Start(":1500")
|
|
||||||
|
|
||||||
return events.APIGatewayProxyResponse{
|
|
||||||
Body: string(b[:]),
|
Body: string(b[:]),
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
}, nil
|
}, nil
|
||||||
BIN
backend/amazon/Task_API_service/Task_API/bin/Task_API
Normal file
BIN
backend/amazon/Task_API_service/Task_API/bin/Task_API
Normal file
Binary file not shown.
BIN
backend/amazon/Task_API_service/Task_API/bin/Task_API.zip
Normal file
BIN
backend/amazon/Task_API_service/Task_API/bin/Task_API.zip
Normal file
Binary file not shown.
5
backend/serverless/GO_API_service/.gitignore
vendored
5
backend/serverless/GO_API_service/.gitignore
vendored
@@ -1,5 +0,0 @@
|
|||||||
# Serverless directories
|
|
||||||
.serverless
|
|
||||||
|
|
||||||
# golang output binary directory
|
|
||||||
bin
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
build:
|
|
||||||
go get github.com/aws/aws-lambda-go/lambda
|
|
||||||
go get github.com/aws/aws-lambda-go/events
|
|
||||||
env GOOS=linux go build -ldflags="-s -w" -o bin/GO_API GO_API/server.go
|
|
||||||
zip deployment.zip bin/GO_API
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
# Welcome to Serverless!
|
|
||||||
#
|
|
||||||
# This file is the main config file for your service.
|
|
||||||
# It's very minimal at this point and uses default values.
|
|
||||||
# You can always add more config options for more control.
|
|
||||||
# We've included some commented out config examples here.
|
|
||||||
# Just uncomment any of them to get that config option.
|
|
||||||
#
|
|
||||||
# For full config options, check the docs:
|
|
||||||
# docs.serverless.com
|
|
||||||
#
|
|
||||||
# Happy Coding!
|
|
||||||
|
|
||||||
service: GO_API_service
|
|
||||||
|
|
||||||
# You can pin your service to only deploy with a specific Serverless version
|
|
||||||
# Check out our docs for more details
|
|
||||||
# frameworkVersion: "=X.X.X"
|
|
||||||
|
|
||||||
provider:
|
|
||||||
name: aws
|
|
||||||
runtime: go1.x
|
|
||||||
|
|
||||||
# you can overwrite defaults here
|
|
||||||
# stage: dev
|
|
||||||
# region: us-east-1
|
|
||||||
|
|
||||||
# you can add statements to the Lambda function's IAM Role here
|
|
||||||
# iamRoleStatements:
|
|
||||||
# - Effect: "Allow"
|
|
||||||
# Action:
|
|
||||||
# - "s3:ListBucket"
|
|
||||||
# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
|
|
||||||
# - Effect: "Allow"
|
|
||||||
# Action:
|
|
||||||
# - "s3:PutObject"
|
|
||||||
# Resource:
|
|
||||||
# Fn::Join:
|
|
||||||
# - ""
|
|
||||||
# - - "arn:aws:s3:::"
|
|
||||||
# - "Ref" : "ServerlessDeploymentBucket"
|
|
||||||
# - "/*"
|
|
||||||
|
|
||||||
# you can define service wide environment variables here
|
|
||||||
# environment:
|
|
||||||
# variable1: value1
|
|
||||||
|
|
||||||
package:
|
|
||||||
exclude:
|
|
||||||
- ./**
|
|
||||||
include:
|
|
||||||
- ./bin/**
|
|
||||||
|
|
||||||
functions:
|
|
||||||
GO_API:
|
|
||||||
handler: bin/GO_API
|
|
||||||
events:
|
|
||||||
- http:
|
|
||||||
path: all
|
|
||||||
method: get
|
|
||||||
|
|
||||||
# The following are a few example events you can configure
|
|
||||||
# NOTE: Please make sure to change your handler code to work with those events
|
|
||||||
# Check the event documentation for details
|
|
||||||
# events:
|
|
||||||
# events:
|
|
||||||
# - http:
|
|
||||||
# path: users/create
|
|
||||||
# method: get
|
|
||||||
# - s3: ${env:BUCKET}
|
|
||||||
# - schedule: rate(10 minutes)
|
|
||||||
# - sns: greeter-topic
|
|
||||||
# - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000
|
|
||||||
# - alexaSkill: amzn1.ask.skill.xx-xx-xx-xx
|
|
||||||
# - alexaSmartHome: amzn1.ask.skill.xx-xx-xx-xx
|
|
||||||
# - iot:
|
|
||||||
# sql: "SELECT * FROM 'some_topic'"
|
|
||||||
# - cloudwatchEvent:
|
|
||||||
# event:
|
|
||||||
# source:
|
|
||||||
# - "aws.ec2"
|
|
||||||
# detail-type:
|
|
||||||
# - "EC2 Instance State-change Notification"
|
|
||||||
# detail:
|
|
||||||
# state:
|
|
||||||
# - pending
|
|
||||||
# - cloudwatchLog: '/aws/lambda/hello'
|
|
||||||
# - cognitoUserPool:
|
|
||||||
# pool: MyUserPool
|
|
||||||
# trigger: PreSignUp
|
|
||||||
|
|
||||||
# Define function environment variables here
|
|
||||||
# environment:
|
|
||||||
# variable2: value2
|
|
||||||
|
|
||||||
# you can add CloudFormation resource templates here
|
|
||||||
#resources:
|
|
||||||
# Resources:
|
|
||||||
# NewResource:
|
|
||||||
# Type: AWS::S3::Bucket
|
|
||||||
# Properties:
|
|
||||||
# BucketName: my-new-bucket
|
|
||||||
# Outputs:
|
|
||||||
# NewOutput:
|
|
||||||
# Description: "Description for the output"
|
|
||||||
# Value: "Some output value"
|
|
||||||
2
backend/serverless/Task_API_service/.gitignore
vendored
Normal file
2
backend/serverless/Task_API_service/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Serverless directories
|
||||||
|
.serverless
|
||||||
6
backend/serverless/Task_API_service/Makefile
Normal file
6
backend/serverless/Task_API_service/Makefile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
build:
|
||||||
|
go get github.com/aws/aws-lambda-go/lambda
|
||||||
|
go get github.com/aws/aws-lambda-go/events
|
||||||
|
set GOOS=linux
|
||||||
|
go build -o bin/Task_API Tasks.go
|
||||||
|
C:\Users\Emir\go\bin\build-lambda-zip.exe -o bin/Task_API.zip bin/Task_API
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/labstack/echo"
|
|
||||||
"github.com/labstack/echo/middleware"
|
|
||||||
"github.com/aws/aws-lambda-go/events"
|
"github.com/aws/aws-lambda-go/events"
|
||||||
"github.com/aws/aws-lambda-go/lambda"
|
"github.com/aws/aws-lambda-go/lambda"
|
||||||
)
|
)
|
||||||
@@ -35,67 +32,17 @@ type Task struct {
|
|||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// This part was used just for testing if the application works correctly
|
|
||||||
/*
|
|
||||||
e := echo.New()
|
|
||||||
|
|
||||||
// Middleware
|
|
||||||
e.Use(middleware.Logger())
|
|
||||||
e.Use(middleware.Recover())
|
|
||||||
|
|
||||||
// CORS
|
|
||||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
|
||||||
AllowOrigins: []string{"*"},
|
|
||||||
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE},
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Getting JSON as []byte
|
|
||||||
b, err := convertTasksToJSON()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route => handler
|
|
||||||
e.GET("/tasks", func(c echo.Context) error {
|
|
||||||
return c.String(http.StatusOK, string(b[:]))
|
|
||||||
})
|
|
||||||
|
|
||||||
// Server
|
|
||||||
e.Start(":1500")
|
|
||||||
*/
|
|
||||||
|
|
||||||
lambda.Start(Handler)
|
lambda.Start(Handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Handler() (events.APIGatewayProxyResponse, error) {
|
func Handler() (events.APIGatewayProxyResponse, error) {
|
||||||
e := echo.New()
|
|
||||||
|
|
||||||
// Middleware
|
|
||||||
e.Use(middleware.Logger())
|
|
||||||
e.Use(middleware.Recover())
|
|
||||||
|
|
||||||
// CORS
|
|
||||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
|
||||||
AllowOrigins: []string{"*"},
|
|
||||||
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE},
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Getting JSON as []byte
|
// Getting JSON as []byte
|
||||||
b, err := convertTasksToJSON()
|
b, err := convertTasksToJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("error:", err)
|
fmt.Println("error:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route => handler
|
return events.APIGatewayProxyResponse {
|
||||||
e.GET("/", func(c echo.Context) error {
|
|
||||||
return c.String(http.StatusOK, string(b[:]))
|
|
||||||
})
|
|
||||||
|
|
||||||
// Server
|
|
||||||
e.Start(":1500")
|
|
||||||
|
|
||||||
return events.APIGatewayProxyResponse{
|
|
||||||
Body: string(b[:]),
|
Body: string(b[:]),
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
}, nil
|
}, nil
|
||||||
BIN
backend/serverless/Task_API_service/Task_API/bin/Task_API
Normal file
BIN
backend/serverless/Task_API_service/Task_API/bin/Task_API
Normal file
Binary file not shown.
BIN
backend/serverless/Task_API_service/Task_API/bin/Task_API.zip
Normal file
BIN
backend/serverless/Task_API_service/Task_API/bin/Task_API.zip
Normal file
Binary file not shown.
19
backend/serverless/Task_API_service/serverless.yml
Normal file
19
backend/serverless/Task_API_service/serverless.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
service: Task_API_service
|
||||||
|
|
||||||
|
provider:
|
||||||
|
name: aws
|
||||||
|
runtime: go1.x
|
||||||
|
|
||||||
|
package:
|
||||||
|
exclude:
|
||||||
|
- ./**
|
||||||
|
include:
|
||||||
|
- ./bin/**
|
||||||
|
|
||||||
|
functions:
|
||||||
|
Task_API:
|
||||||
|
handler: bin/Task_API
|
||||||
|
events:
|
||||||
|
- http:
|
||||||
|
path: /tasks
|
||||||
|
method: get
|
||||||
Reference in New Issue
Block a user