"local-exec" is not able to run the unzip command

Hi,

I’m trying to download a zip file, unzip it to a directory and sync the directory to s3 bucket. I’ve tried using

resource "null_resource" "example3" {
  provisioner "local-exec" {
    command = "unzip -o index2.zip -d index2 "
  }
  depends_on = [module.aws_s3_bucket]
}

resource "null_resource" "example2" {
  provisioner "local-exec" {
    command = "aws s3 sync index2 s3://bucketname/"
  }
  depends_on = [null_resource.example3]
}

i’m not able to unzip a file here. I was able to see the zip file in the workspace but the unzip is not executing here.

Terraform v0.13.6

Error: Error running command ‘aws s3 sync index2 s3://<>/’: exit status 255. Output: The user-provided path index2 does not exist.

I’ve added below to make sure it runs always and also onfailure = fail if it is not able to unzip.

triggers = {
    always_run = timestamp()
  }

This worked. :smiley: