0
votes

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?

1

1 Answers

0
votes

local-exec is running on your local machine instead of the resource. So I would guess you are missing the aws-cli on your machine.

The command which aws will show whether or not you have aws-cli installed and available within your PATH? If it is not installed, follow the installation instructions for your OS.