In this post we will use Terraform to deploy a simple Lambda function written in Python. You can follow the video or continue reading.
Clone the tutorial repository from Github. Change to the newly created directory.
terraform init
This will install and initialize the AWS Provider.
terraform apply
This will package the Python handler and create the Lambda function.
aws lambda invoke --function-name hello_lambda out.txt
This command invokes the Lambda function and should return with:
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
The output is in the out.txt file and should be:
"Hello from Lambda!"
To delete all resources created use:
terraform destroy