Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit 02bf4c3

Browse files
author
Frank Cash
committed
Lambda now pings
1 parent 8b186ef commit 02bf4c3

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
function/main
2121
*.zip
2222

23-
*.tfstate
23+
*.tfstate
24+
*.backup

function/function.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
package main
22

33
import (
4+
"fmt"
5+
"net/http"
6+
47
"github.com/aws/aws-lambda-go/lambda"
58
)
69

7-
func hello() (string, error) {
8-
return "Hello ƛ!", nil
10+
func ping() (string, error) {
11+
url := "http://example.com/"
12+
resp, err := http.Get(url)
13+
return fmt.Sprintf("%s returned %s", url, resp.Status), err
914
}
1015

1116
func main() {
1217
// Make the handler available for Remote Procedure Call by AWS Lambda
13-
lambda.Start(hello)
18+
lambda.Start(ping)
1419
}

main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "us-east-1"
33
}
44

5-
65
resource "aws_iam_role" "lambda_exec_role" {
76
name = "lambda_exec_role"
87
assume_role_policy = <<EOF
@@ -30,4 +29,3 @@ resource "aws_lambda_function" "demo_lambda" {
3029
source_code_hash = "${base64sha256(file("./function/function.zip"))}"
3130
role = "${aws_iam_role.lambda_exec_role.arn}"
3231
}
33-

0 commit comments

Comments
 (0)