Notes
  • Blockchain
  • About this repository
  • References
  • Carret Position
  • Loggia and Balcony
  • automobile
    • Motorbike
  • computer
    • Kubernetes Event-driven Autoscaling (KEDA)
    • Protobuf
    • [[Amazon]] [[Identity and Access Management]] ([[IAM]])
    • Apdex
    • Architecture Decision Record
    • Audio
    • [[Amazon Web Services]] (AWS) Lambda
    • Blockchain
    • C/C++
    • Cache line
    • Caching strategies
    • Database
    • Design Patterns
    • Docker compose
    • Event Driven Design
    • False sharing
    • Git
    • [[Go]] common mistakes
    • [Go] [[subtests]]
    • Go
    • Janus
    • Jest
    • Kubernetes
    • Log-Structured Merge-tree
    • Media server
    • MySQL: Charset, Collation and UCA
    • Netflix
    • Opus Codec
    • Process, Thread
    • ReDoS - [[Regular expression]] Denial of Service
    • Rust
    • ScyllaDB
    • Shell Functions
    • Signals (The GNU Library)
    • Solidity
    • Sources
    • SQL
    • Transmission Control Protocol (TCP)
    • Ten design principles for Azure applications
    • Transient Fault Handling
    • twemproxy
    • Video
    • Web2 vs Web3
    • WebRTC
    • Microservice architecture
      • 3rd party registration
      • Command Query Responsibility Segregation (CQRS)
      • Access token
      • Aggregate
      • API Composition
      • API gateway/Backends for Frontends
      • Application metrics
      • Audit logging
      • Circuit Breaker
      • Client-side discovery
      • Client-side UI composition
      • Consumer-driven contract test
      • Consumer-side contract test
      • Database per Service
      • Decompose by business capability
      • Decompose by subdomain
      • Distributed tracing
      • Domain event
      • Domain-specific
      • Event sourcing
      • Exception tracking
      • Externalized configuration
      • Health check API
      • Log aggregation
      • Log deployments and changes
      • Messaging
      • Microservice architecture
      • Microservice Chassis
      • Multiple Service instances per host
      • Polling publisher
      • Remote Procedure invocation
      • Saga
      • Self-contained service
      • Self registration
      • Server-side discovery
      • Server-side page fragment composition
      • Serverless deployment
      • Service Component test
      • Service deployment platform
      • Service instance per Container
      • Service instance per VM
      • Service mesh
      • Service per team
      • Service registry
      • Service template
      • Shared database
      • Single Service instance per host
      • Transaction log tailling
      • Transactional outbox
  • food-and-beverage
    • Cheese
    • Flour
    • Japanese Plum liqueur or Umeshu
    • Sugar
  • management
    • Software Engineering processes
  • medic
    • Desease, disorder, condition, syndrome
    • Motion Sickess
  • others
    • Elliðaey
    • ASCII art
    • Empirical rule
    • Hindsight bias
    • Outcome bias
    • Tam giác Reuleaux
    • Luật Việt Nam
  • soft-skills
    • Emotional intelligence
Powered by GitBook
On this page
  • How to Deploy AWS Lambda on AWS
  • With [Go]
  1. computer

[[Amazon Web Services]] (AWS) Lambda

How to Deploy AWS Lambda on AWS

  1. Create Lambda function:

    1. In Console, search for Lambda.

    2. In Lambda page, choose Create function.

    3. In next page:

      1. Function name: helloLambda, for example.

      2. Runtime: your language, for example: Go.

      3. Execution role: Create a new role from aws policy templates

      4. Role Name: helloLambda-executor - and choose Simple microservice permission

  2. Creat API:

    1. In Console search for API Gateway

    2. In section of REST Api, click Build button.

    3. In the next page, choose:

      1. Protocol: REST

      2. Create new API: New API

      3. API name: helloLambdaAPI

    4. After click Create API button, on the next screen:

      1. Click select box Action and select Create API option.

      2. Select:

        1. Integration type: Lambda Function

        2. Use Lambda Proxy integration: check

        3. Lambda Function: helloLambda

        4. Use Default Timeout: check

Demo project: https://github.com/ducminhgd/go-lambda

Simple steps:

  1. Make sure that you install the dependencies go get -v all.

  2. Build project GOOS=linux go build -o build/main cmd/main.go.

  3. Zip binary to upload to AWS zip -jrm build/main.zip build/main

  4. If you want to handle request and response in your code, then please make sure that the field Use Lambda Proxy integration in Integration Request checked.

Sample code

package main

import (
	"context"
	"fmt"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
)

func HandleRequest(ctx context.Context, req events.APIGatewayProxyRequest) (*events.APIGatewayProxyResponse, error) {
	name, found := req.QueryStringParameters["name"]
	if !found {
		name = "Anonymous"
	}
	resp := events.APIGatewayProxyResponse{Headers: map[string]string{"Content-Type": "text/plain"}}
	resp.StatusCode = 200
	resp.Body = string(fmt.Sprintf("Hello, %s! Welcome to AWS Lambda", name))
	return &resp, nil
}

func main() {
	lambda.Start(HandleRequest)
}
PreviousAudioNextBlockchain

Last updated 2 years ago

With []

Go