Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created example for creating an AWS Lambda in Go #553

Merged
merged 6 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed it so it actually works
  • Loading branch information
Tasia Halim authored and Tasia Halim committed Feb 12, 2020
commit b09df440e4c8146e00642dba2c4bd86d68a0543d
4 changes: 4 additions & 0 deletions aws-go-lambda/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be inevitable - but having a Makefile here means this may not work well on Windows. There are some notes on doing this in a cross platform compatible way in https://github.com/aws/aws-lambda-go/blob/master/README.md#for-developers-on-windows.

GOOS=linux GOARCH=amd64 go build -o ./handler/handler ./handler/handler.go
zip -j ./handler/handler.zip ./handler/handler
go build -o go-lambda main.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this last line?

Copy link
Author

@tasiah tasiah Feb 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the example I was referring to, the first step was to build go, but to be honest, I've never tried not building it.

EDIT: Just tried it on a different example, and seems like the changes to main.go don't persist unless I build it first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: Just tried it on a different example, and seems like the changes to main.go don't persist unless I build it first.

My understanding is that if you have the binary there, then it will be used, but if you don't, then we will effectively go run main.go. So what you are seeing might happen if you still have the binary there from a previous go build?

@EvanBoyle Is that right? And if so, is it documented yet?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested, and you're right that pulumi builds for us. I'll make this change with #554.

Binary file removed aws-go-lambda/handler/handler
Binary file not shown.
10 changes: 6 additions & 4 deletions aws-go-lambda/handler/handler.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package handler
package main

import (
"strings"

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

func Handler() (string, error) {
return "hello", nil
func handler(str string) (string, error) {
return strings.ToUpper(str), nil
}

func main() {
lambda.Start(Handler)
lambda.Start(handler)
}
Binary file removed aws-go-lambda/handler/handler.zip
Binary file not shown.
2 changes: 0 additions & 2 deletions aws-go-lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"github.com/pulumi/pulumi-aws/sdk/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/go/aws/lambda"
"github.com/pulumi/pulumi/sdk/go/pulumi"

_ "github.com/pulumi/examples/aws-go-lambda/handler"
)

func main() {
Expand Down