Skip to content

Example Lambda function using harrisonhjones.com/go-apigw-http-adapter

License

Notifications You must be signed in to change notification settings

harrisonhjones/go-apigw-http-adapter-lambda-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-apigw-http-adapter-lambda-example

Example AWS Lambda function utilizing the harrisonhjones.com/go-apigw-http-adapter package for both HTTP and REST APIs.

Badges

  • Build: Build
  • Report Card: Go Report Card

Links

Contributing

  1. Make changes.
  2. Add / update tests.
  3. Run make to fmt, vet, test, and build your changes.
  4. Follow the Testing steps below to deploy your changed binary to Lambda and test it.
  5. Commit your changes.
  6. Submit a PR.

Testing

Building

  1. Git clone this project.
  2. Run make. Two binaries and zip files will be created in the bin directory.

Running Locally

HTTP API

  1. Run ./bin/httpapi to
    1. Open http://localhost:8080 in your browser.
    2. You should see a web page served, an image, and a favicon (see the demo above).

REST API

  1. Run ./bin/restapi to
  2. Open http://localhost:8080/home in your browser.
  3. You should see a web page served, an image, and a favicon (see the demo above).

Deploying to Lambda and API Gateway

HTTP API

  1. Create a new AWS Lambda function using the AWS Lambda console.
    1. Make sure the Go 1.x runtime is chosen.
  2. Upload the httpapi.zip file to the Lambda function.
  3. Update the handler to be httpapi.
  4. Create a new HTTP API in the AWS API Gateway console.
  5. Set the integration to the Lambda function created earlier.
    1. Make sure the version is 2.0.
  6. Create a route with path $default.
    1. This will set the "method" to ANY.
  7. Leave all the other options as the defaults.
  8. Create the API and test it by going to INVOKEURL.

REST API

  1. Create a new AWS Lambda function using the AWS Lambda console.
    1. Make sure the Go 1.x runtime is chosen.
  2. Upload the restapi.zip file to the Lambda function.
  3. Update the handler to be restapi.
  4. Create a new REST API in the AWS API Gateway console.
  5. Create a new method set to use the Lambda function created earlier.
    1. Make sure it's setup to be a proxy integration.
  6. Set the Binary Media Types to image/*.
  7. Deploy the method using any stage name.
  8. Leave all the other options as the defaults.
  9. Create the API and test it by going to INVOKEURL/home.

About

Example Lambda function using harrisonhjones.com/go-apigw-http-adapter

Resources

License

Stars

Watchers

Forks

Packages

No packages published