A simple program that will build the infrastructure to ping a website.
go get github.com/aws/aws-lambda-go/lambda
The Go program exists inside of function/. main.tf is the Terraform configuration for the Lambda.
Change url := "http://example.com/" to url := "<desired-site>" in function/function.go.
In the function directory run make release to generate the binary and then zip it.
-
Run
terraform initto initialize the terraform repository. -
Then run
terraform planto create the execution plan. -
Finally,
terraform applyto apply the changes (run the execution plan).
aws lambda invoke \
--invocation-type RequestResponse \
--function-name demo_lambda \
--region us-east-1 \
--log-type Tail \
--payload '{"key1":"value1", "key2":"value2", "key3":"value3"}' \
outputfile.txt