Deploy a lambda function with Terraform
- Lambda Function
- IAM Role and Policy for Lambda
- Lambda Layer
Please make sure following software installed in local system.
- pip
- python 3.7
- zip
- terraform
# Download repo
git clone git@github.com:nitinda/terraform_lambda_awscli.git
cd terraform_lambda_awscli/module_lambda/awscli_layers_payload
mkdir python
# Download the required site packages for python
pip install awscli -t ./python
cd python
ln -s bin/aws
ln -s bin/aws-list-all
# Setup the python location
sed -i "1s/.*/\#\!\/var\/lang\/bin\/python/" bin/aws bin/aws-list-all
# Create layer payload archive
zip -r ../../lambda_function/terraform-demo-awscli-lambda-layer-payload.zip python/
# Download Repo
cd terraform_lambda_awscli/layer
terraform init
terraform plan
terrafomr apply --auto-approve
- Test the deployed lambda with any test event.
You can destroy this cluster entirely by running:
terraform plan -destroy
terraform destroy --force --auto-approve