I want to perform a lambda invocation from terraform when destroy is running. The terraform job is run by Jenkins on remote server.
According to this documentation I defined the following provisioner:
provisioner "local-exec" {
when = destroy
command = "aws lambda invoke --function-name ${var.lambda_name} --payload '{ \"someProperty\": \"someValue\" }' response.json"
}
the command syntax of lambda invoke is according to AWS CLI Command Reference
But, when running Terraform getting the following error:
Error running command 'aws lambda invoke --function-name my-lambda-name --payload '{ "someProperty": "someValue" }' response.json': exit status 127. Output: /bin/sh: aws: command not found
Why do I get /bin/sh: aws: command not found in local-exec provisioner?