Tutorials from free code camp youtube video here
image of slack file bot output
image of slack file bot output // provide a domain and the app will return if its a valid domain or not
create role
aws iam create-role --role-name lambda-ex --assume-role-policy-document '{"Version": "2012-10-17","Statement": [{ "Effect": "Allow", "Principal": {"Service": "lambda.amazonaws.com"}, "Action": "sts:AssumeRole"}]}'
create file in the root directory of your main.go called trust-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
point the aws-cli to the trust policy file just created
aws iam create-role --role-name lambda-ex --assume-role-policy-document file://trust-policy.json
configure policy/role
aws iam attach-role-policy --role-name lambda-ex --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
build the go binary (if trouble, run 'go mod tidy')
go build main.go
zip the built "main" into a zip called function.zip
zip function.zip main
create the lambda function with aws cli (replace 123456789012 with your aws account id)
aws lambda create-function --function-name test-lambda-go-func --zip-file fileb://function.zip --handler main --runtime go1.x --role arn:aws:iam::123456789012:role/lambda-ex
invoke the lambda function
aws lambda invoke --function-name test-lambda-go-func --cli-binary-format raw-in-base64-out --payload '{"What is your name?": "Jim", "How old are you?": 33}' output.txt
Console Output:
Database View:
NOTE: May need to install sqlite
sudo apt install sqlite
Console Output:
ABOUT: This app uses Slack, wit.ai, wolfram, and go to create a slack bot that takes a general request and returns an answer.
ABOUT: From a discord ping bot series with Akhil.
NOTE: discord link for authorizing bots:
https://discord.com/oauth2/authorize?client_id=<APPLICATION_ID>&scope=bot
where, APPLICATION_ID is found in your discord developer portal