Encrypt Lambda source code using `aws_lambda_function`

I am deploying a Lambda Function using Terraform, but I can’t find a way to encrypt the source code. Is this possible using Terraform, or will I instead have to use CloudFormation?

AWS provide the SourceKMSKeyArn property for the CloudFormation resource AWS::Lambda::Function Code object, but I can’t find any equivilent for the Terraform aws_lambda_function resource.

The only KMS argument that appears to exist is kms_key_arn which mirrors the CloudFormation property KmsKeyArn, and this is used to encrypt environment variables rather that the source code.

Hopefully I’m missing something and this is entirely possible?

Thanks

I got the same issue while trying to encrypt the lambda code. It seems they have not yet added a feature in terraform to encrypt lambda code using cmk. Did you find any solution for this ?