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
added comments and a README
  • Loading branch information
Tasia Halim authored and Tasia Halim committed Feb 12, 2020
commit 83cda13ab05d0a500dde02b64666c061de36e879
52 changes: 52 additions & 0 deletions aws-go-lambda/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# AWS Golang Lambda
This example creates a lambda that does a simple `ToUpper` on the string input and returns it.

## Deploying the App

To deploy your infrastructure, follow the below steps.

### Prerequisites

1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/)
2. [Configure AWS Credentials](https://www.pulumi.com/docs/intro/cloud-providers/aws/setup/)
3. [Clone aws-go-lambda](https://github.com/aws/aws-lambda-go)

### Steps

After cloning this repo, run these commands from the working directory:

1. Build the go files:

```bash
make build
Copy link
Member

Choose a reason for hiding this comment

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

Btw - I’m hopeful that once we fix pulumi/pulumi#3593 we can automate this directly within the Pulumi program so that the separate step is not needed - but today I think it is so I like having this example as is until then.

```

2. Create a new Pulumi stack, which is an isolated deployment target for this example:

```bash
pulumi stack init
```

3. Set the required configuration variables for this program:
```bash
pulumi config set aws:region us-east-1
```

4. Execute the Pulumi program to create our lambda:

```bash
pulumi up
```

5. Call our lambda function from the aws cli

```bash
aws lambda invoke \
--function-name $(pulumi stack output lambda) \
--region $(pulumi config get aws:region) \
--payload '"foo"' \
output.json

cat output.json # view the output file with your tool of choice
# "FOO"
```
1 change: 1 addition & 0 deletions aws-go-lambda/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-lambda-go/lambda"
)

// handler is a simple function that takes a string and does a ToUpper.
func handler(str string) (string, error) {
return strings.ToUpper(str), nil
}
Expand Down
2 changes: 1 addition & 1 deletion aws-go-lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func main() {
return err
}

// Stack exports
// Export the lambda ARN.
ctx.Export("lambda", function.Arn)

return nil
Expand Down