A simple Terraform provider to invoke a syncronous AWS Lambda function and provide the output.
Similar to the HTTP provider.
Example Lambda Function: hello
import json
# Return the JSON event that we receive
def lambda_handler(event, context):
e = json.dumps(event, indent=2)
return e
Example Terraform config:
data "lambda_function_invoke" "hello" {
fn_name = "hello"
payload = {
foo = "bar"
}
}
output "lambda_output" {
value = "${data.lambda_function_invoke.hello.*.response}"
}
Example terminal session:
$ terraform apply
data.lambda_function_invoke.hello: Refreshing state...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
lambda_output = [
{
foo = bar
}
]