Filebase64sha256 and Terraform

Adrian Macal
Nov 5, 2020

--

To deploy lambda function or layer you need to provide the zipped code and its source hash, calculated by the filebase64sha256 function. It might cross your memory limits. Here I show you how to avoid it.

The Problem

Calculating hash value is CPU expensive problem and memory should not impact it at all. Unfortunately Terraform loads entire file to memory to calculate hash of it which may cause killing the process.

Calculate in BASH

Utilize bash and OpenSSL to calculate it and return as JSON.

External resource

Reference bash script and use its outputs in lambda resources.

--

--

Adrian Macal
Adrian Macal

Written by Adrian Macal

Software Developer, Data Engineer with solid knowledge of Business Intelligence. Passionate about programming.

No responses yet