Skip to content

Commit

Permalink
working around terraform issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieudolci committed Nov 25, 2019
1 parent 1f3471d commit b830745
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand All @@ -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
Expand All @@ -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
19 changes: 16 additions & 3 deletions terraform/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b830745

Please sign in to comment.