filmov
tv
AWS: Creating a Lambda using GoLang and deploying it using Terraform

Показать описание
AWS: Creating a Lambda using GoLang and deploying it using Terraform
Quick tutorial on how to create AWS Lambda using GoLang, compiling and deploying it using Terraform
-----
Topics:
- Create GoLang lambda
- Compile for AWS expected binary
- Create Terraform for your lambda
- Deploy and invoke lambda
-----
Commands used:
terraform init
terraform apply
-----
Code:
package main
import (
"fmt"
)
type MyInput struct {
Action string `json:"action"`
Data string `json:"data"`
}
type MyResponse struct {
StatusCode string `json:"statusCode"`
StatusMessage string `json:"statusMessage"`
}
func handle(event MyInput) (MyResponse, error) {
fmt.Printf("%v\n", event)
return MyResponse{StatusCode: "200", StatusMessage: "Success"}, nil
}
func main() {
lambda.Start(handle)
}
-----
Terraform:
provider "aws" {
region = "us-east-2"
profile = "dev-01"
}
resource "aws_lambda_function" "dev-golambda" {
function_name = "dev-golambda"
handler = "golambdabin"
runtime = "go1.x"
role = "YOUR ARN ROLE HERE"
memory_size = 128
timeout = 10
}
-----
Thank you so much for watching! If you liked, please come back soon for more examples shortly.
In the future I will also add SNS, Elastic Search, Kibana and other examples.
If there is another AWS serverless topic you are interested, please add a comment and I will do my best to show an example using it.
See you soon!
-- Contents of this video --
0:00 Intro
0:31 Create GoLang lambda
1:57 Compile for AWS expected binary
3:00 Create Terraform for your lambda
4:35 Deploy and invoke lambda
Quick tutorial on how to create AWS Lambda using GoLang, compiling and deploying it using Terraform
-----
Topics:
- Create GoLang lambda
- Compile for AWS expected binary
- Create Terraform for your lambda
- Deploy and invoke lambda
-----
Commands used:
terraform init
terraform apply
-----
Code:
package main
import (
"fmt"
)
type MyInput struct {
Action string `json:"action"`
Data string `json:"data"`
}
type MyResponse struct {
StatusCode string `json:"statusCode"`
StatusMessage string `json:"statusMessage"`
}
func handle(event MyInput) (MyResponse, error) {
fmt.Printf("%v\n", event)
return MyResponse{StatusCode: "200", StatusMessage: "Success"}, nil
}
func main() {
lambda.Start(handle)
}
-----
Terraform:
provider "aws" {
region = "us-east-2"
profile = "dev-01"
}
resource "aws_lambda_function" "dev-golambda" {
function_name = "dev-golambda"
handler = "golambdabin"
runtime = "go1.x"
role = "YOUR ARN ROLE HERE"
memory_size = 128
timeout = 10
}
-----
Thank you so much for watching! If you liked, please come back soon for more examples shortly.
In the future I will also add SNS, Elastic Search, Kibana and other examples.
If there is another AWS serverless topic you are interested, please add a comment and I will do my best to show an example using it.
See you soon!
-- Contents of this video --
0:00 Intro
0:31 Create GoLang lambda
1:57 Compile for AWS expected binary
3:00 Create Terraform for your lambda
4:35 Deploy and invoke lambda
Комментарии