lambda-go | working example for developing Alexa Skills Kit | AWS library
kandi X-RAY | lambda-go Summary
kandi X-RAY | lambda-go Summary
A working example for developing Alexa Skills Kit for your Amazon Echo with AWS Lambda. This example wraps a Go executable/process in an Node.js wrapper. Yes, Go works just fine on AWS.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- processRequest takes an AlexaSkillEvent and returns a Alexa response .
- The Alexa skill events
- generates Alexa response
lambda-go Key Features
lambda-go Examples and Code Snippets
Community Discussions
Trending Discussions on lambda-go
QUESTION
I'm performing a simple table Scan to get all items from my DynamoDB table, products
. Here is the whole Lambda:
ANSWER
Answered 2022-Apr-03 at 18:40Scanning the table returns the map of items and you want to convert map into the struct so in order to convert the list of maps to the struct you want to use attributevalue.UnmarshalListOfMaps under aws-sdk-go-v2. In the previous version it was in the dynamodbattribute but they decided to change the package in the v2.
QUESTION
I use API Gatway to trigger Lambda with proxy integration
I build a lambda container image for Golang from public.ecr.aws/lambda/provided:al2 because of depedency that cannot be installed in public.ecr.aws/lambda/go:latest.
PFB for my Docerfile
content
ANSWER
Answered 2021-Dec-16 at 12:50Found the issue
since the handler function expectes interface
the request
is passed as map[string]interface{}
after I changed the type of the request
parameter to events.APIGatewayProxyRequest
my code automatically started to receive in this type.
QUESTION
I'm trying to call another lambda function using the following code:
...ANSWER
Answered 2021-Oct-11 at 09:34Based on your code snipped, it looks as if you are using the AWS SDK for Go V2. It is recommended to use the AWS SDK for Go V2 (please review the Migrating to the AWS SDK for Go V2 documentation).
Please initialize a Go Modules project (as described on the SDK's Github page):
QUESTION
I'm new with golang.
I've been looking documentation of lambda-golang-AWS and still had this timeout in when invoking the function.
I've been configuring:
- Elasticache cluster (1 primary node),
- VPC (one same VPC for redis and lambda),
- Security groups,
- Subnets,
- Inbound and outbound,
- role
I have this primary Redis endpoint xxxxxx
I just need an example.
So, my questions are:
- Can we connect Redis in Linux without an EC2 instance? Possibly try it with RDM.
- How do we put AWS redis's endpoint in the main function? (do we only need the endpoint? or else)
- Is it possible to connect to Redis Elasticache with only endpoint (without AUTH)?
Thanks a lot!
...ANSWER
Answered 2021-Sep-13 at 16:20Can we connect Redis in Linux without an EC2 instance?
Yes, of course, why would an EC2 instance be an additional requirement? You just need to include a Redis client library in your Lambda function's deployment artifact, and configure the Elasticache cluster to allow inbound traffic from the security group assigned to the Lambda function.
How do we put AWS redis's endpoint in the main function? (do we only need the endpoint? or else)
I would configure the endpoint as one of the Lambda function's environment variables.
Is it possible to connect to Redis Elasticache with only endpoint (without AUTH)?
If you don't enable AUTH on Elasticache, then you can connect without AUTH. AUTH is an optional configuration setting.
QUESTION
I need to get the values out of the following data that is from the Go SDK (https://docs.aws.amazon.com/sdk-for-go/api/service/apigateway/#Usage). I am using golang 1.17.
Below is the data returned by my lambda function.
...ANSWER
Answered 2021-Sep-02 at 14:54To get the two numbers you would have to fetch them from the map. If you always know the key and you know that there will only be one element in the array you can do it like this
QUESTION
I got this code from https://github.com/aws/aws-lambda-go/blob/master/events/README_ApiGatewayEvent.md :
...ANSWER
Answered 2021-Aug-16 at 09:23Though i am not familiar with the lambda GUI i suspect that there you input the json representation of the request (with headers and body), but when sending via curl, you don't need to wrap the body (-d), so just send it like this [{\"id\":\"123\"}]
as this is what the body should contain.
QUESTION
This first example is non-problematic code:
You make a lambda out of this:
...ANSWER
Answered 2021-Aug-14 at 20:26When you proxy the request through some other AWS event source, the payload sent to the lambda gets wrapped into an event object.
In the case of API Gateway, the payload is a events.APIGatewayProxyRequest
, which is not a slice, and can't be marshalled into a []interface{}
.
The aws-lambda-go
github repo has a piece of documentation that shows how to build the handler. In short:
QUESTION
Why am I getting this error message? I'm a beginner at using aws sam and golang.
...ANSWER
Answered 2021-Jul-12 at 06:40You need to set up your Go project properly for dependency management. First follow the steps for initializing the project as described in Tutorial: Get started with Go:
QUESTION
Looking at the Using global state section in the official AWS Lambda function handler in Go doc https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html
suggests to initialise all global state in func init()
i.e. Any package level vars which we want to share across multiple lambda invocations go here.
And my understanding is that this initialisation is done once per lambda container start (i.e cold start).
My question is, is it possible to do the same using func main()
instead of func init()
.
Using func init()
basically makes my handler function (func LambdaHandler
) non unit-testable due to side-effects from func init()
running.
Moving the func init()
code to func main()
seems to solve this easily.
Are there any side effects to using func main()
vs func init()
Code Example
Using func init()
...ANSWER
Answered 2021-Jun-03 at 16:35I would propose the following (which we use successful in a lot of Go Lambdas).
main.go
QUESTION
I'm trying to write simple POST serverless Go AWS lambda function.
...ANSWER
Answered 2021-Jun-03 at 15:20As the error says, your use of ,string
is invalid for your JSON input. Remove it:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install lambda-go
git clone https://github.com/jsgoecke/lambda-go.git
Change the LAMBDA_PROC variable in the file 'build.sh' to the name of your Lambda function on AWS Lambda
Setup an AWS Lambda function with the name set for LAMBDA_PROC in build.sh
Setup an AWS S3 Bucket with the same name set for LAMBDA_PROC in build.sh
Setup an Alex Skill with the 'Alexa Skills Settings' and pointing to your AWS Lambda function, its recommended to use ARN
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page