Skip to content

Commit f802d2b

Browse files
author
Scott Miller
committed
properly retrieve shasum
1 parent 6054922 commit f802d2b

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
@@ -32,11 +32,14 @@ resource "null_resource" "lambda_zip" {
3232
}
3333
}
3434

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

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

@@ -88,7 +91,6 @@ data "aws_iam_policy_document" "lambda_policy_doc" {
8891
"*"
8992
]
9093
}
91-
9294
}
9395

9496
resource "aws_iam_role_policy" "this" {
@@ -111,7 +113,7 @@ resource "aws_lambda_function" "this" {
111113
handler = "rolling-restart.handler"
112114
runtime = "python3.6"
113115
timeout = 600
114-
source_code_hash = data.http.shasum.body
116+
source_code_hash = data.external.sha.result.sha
115117
tags = module.tags.tags
116118

117119
environment {

0 commit comments

Comments
 (0)