diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b9dec24..2895d91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,11 +24,6 @@ jobs: make build CMD=check make build CMD=copy - - name: zip builds - run: | - zip --junk-paths check.zip ./build/check/main - zip --junk-paths copy.zip ./build/copy/main - - name: Create Release id: create_release uses: actions/create-release@v1.0.0 @@ -47,9 +42,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./check.zip - asset_name: check.zip - asset_content_type: application/zip + asset_path: ./build/check/main + asset_name: check + asset_content_type: application/octet-stream - name: Upload Copy Asset id: upload-copy-asset @@ -58,6 +53,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./copy.zip - asset_name: copy.zip - asset_content_type: application/zip + asset_path: ./build/copy/main + asset_name: copy + asset_content_type: application/octet-stream diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 0b15c9b..b2522a9 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -20,7 +20,7 @@ EOF resource "null_resource" "get_release" { provisioner "local-exec" { - command = "wget -O ${path.root}/check.zip https://github.com/techdroplabs/rdscheck/releases/download/${var.release_version}/${var.command}.zip" + command = "wget -O ${path.module}/lambda-files/${var.command} https://github.com/techdroplabs/rdscheck/releases/download/${var.release_version}/${var.command}" } # We do that so null_resource is called everytime we run terraform apply or plan @@ -29,12 +29,25 @@ resource "null_resource" "get_release" { } } +data "null_data_source" "wait_for_get_release" { + inputs = { + get_release_id = "${null_resource.get_release.id}" + source_dir = "${path.module}/lambda-files/" + } +} + +data "archive_file" "lambda_code" { + type = "zip" + source_dir = "${data.null_data_source.wait_for_get_release.outputs["source_dir"]}" + output_path = "${path.module}/${var.command}.zip" +} + resource "aws_lambda_function" "rdscheck_lambda" { - filename = "${path.root}/${var.command}.zip" + filename = "${data.archive_file.lambda_code.output_path}" function_name = "${var.command}-rdscheck" role = "${aws_iam_role.rdscheck_iam_role.arn}" handler = "main" - source_code_hash = "${base64sha256(file("${path.root}/${var.command}.zip"))}" + source_code_hash = "${data.archive_file.lambda_code.output_base64sha256}" runtime = "go1.x" memory_size = 128 timeout = 120