Deploy Lambda function with Terraform

Deploy Lambda function with Terraform

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

Clone the tutorial repository from Github. Change to the newly created directory.

Initialize Terraform

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
comments powered by Disqus