I am trying to update my scripts to update a lambda from a jar stored in S3.
Right now I am deploying code to an S3 bucket, and another file containing the SHA for the jar. I’m generating the SHA of the jar using
openssl dgst -sha256 -binary "./target/$FILENAME.jar" | openssl enc -base64 >./target/$FILENAME.sha256
I have a data element described as
data "aws_s3_bucket_object" "java_lambda_code_sha" {
bucket = var.artifacts_s3_bucket
key = “my-jar.1.0-SNAPSHOT.sha256”
}
And then my lambda uses it as
resource "aws_lambda_function" "the_lambda" {
depends_on = [
data.aws_s3_bucket_object. java_lambda_code_sha]
s3_bucket = var.artifacts_s3_bucket
s3_key = “my-jar.1.0-SNAPSHOT.jar”
source_code_hash = data.aws_s3_bucket_object. java_lambda_code_sha.body
…
I’m not sure what I’m doing wrong. When I update the jar, I create a new sha file. When I run an apply, the lambda is not updated.
How should I be doing this? Thanks!