Skip to content

Commit

Permalink
Update archive creation to remove temporary local file.
Browse files Browse the repository at this point in the history
Since updating to terraform 0.13 we've been receiving the following error:

```
Error: error archiving file: could not archive missing file: .terraform/modules/es-cleanup/es-cleanup.py

  on .terraform/modules/es-cleanup/lambda.tf line 11, in data "archive_file" "es_cleanup_lambda":
  11: data "archive_file" "es_cleanup_lambda" {
```

This change builds the archive file directly from the downloaded file without a local file instance: https://registry.terraform.io/providers/hashicorp/archive/1.3.0/docs/data-sources/archive_file
  • Loading branch information
lewchuk-span committed Oct 23, 2020
1 parent 03d6dfa commit 6e84dac
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ data "http" "src" {
url = "https://raw.githubusercontent.com/cloudreach/aws-lambda-es-cleanup/master/es_cleanup.py"
}

resource "local_file" "src_local" {
content = "${data.http.src.body}"
filename = "${path.module}/es-cleanup.py"
}
data "archive_file" "es_cleanup_lambda" {
type = "zip"

source {
content = "${data.http.src.body}"
filename = "es-cleanup.py"
}

data "archive_file" "es_cleanup_lambda" {
type = "zip"
source_file = "${path.module}/es-cleanup.py"
output_path = "${path.module}/es-cleanup.zip"
depends_on = [
local_file.src_local,
]
}

locals {
Expand Down

0 comments on commit 6e84dac

Please sign in to comment.