Skip to content

Commit effc1b2

Browse files
author
Scott Miller
committed
properly retrieve shasum
1 parent 4b61af2 commit effc1b2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

getsha.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /usr/bin/env bash
2+
ARGS=($(jq -r --unbuffered '.repo_full_name,.tag'))
3+
curl -Ls "https://github.com/${ARGS[0]}/releases/download/${ARGS[1]}/lambda.sha256base64" | jq -cR '{"sha": .}'

main.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ resource "null_resource" "lambda_zip" {
3333
}
3434
}
3535

36-
data "http" "shasum" {
37-
url = "https://github.com/${local.repo_full_name}/releases/download/${local.lambda_version_tag}/lambda.sha256base64"
36+
data "external" "sha" {
37+
program = [
38+
"${path.module}/getsha.sh"
39+
]
3840

39-
request_headers = {
40-
Accept = "text/plain"
41+
query = {
42+
repo_full_name = local.repo_full_name
43+
tag = local.lambda_version_tag
4144
}
4245
}
4346

@@ -89,7 +92,6 @@ data "aws_iam_policy_document" "lambda_policy_doc" {
8992
"*"
9093
]
9194
}
92-
9395
}
9496

9597
resource "aws_iam_role_policy" "this" {
@@ -112,7 +114,7 @@ resource "aws_lambda_function" "this" {
112114
handler = "rolling-restart.handler"
113115
runtime = "python3.6"
114116
timeout = 600
115-
source_code_hash = data.http.shasum.body
117+
source_code_hash = data.external.sha.result.sha
116118
tags = module.tags.tags
117119

118120
environment {

0 commit comments

Comments
 (0)