Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when terraform apply is run multiple times #698

Closed
tasdomas opened this issue Oct 19, 2022 · 2 comments
Closed

Error when terraform apply is run multiple times #698

tasdomas opened this issue Oct 19, 2022 · 2 comments

Comments

@tasdomas
Copy link
Contributor

No description provided.

@tasdomas
Copy link
Contributor Author

@dacbd - tested several variations of this with aws and could not reproduce an error. Could you provide more information on what kind of an error you saw?

@dacbd
Copy link
Contributor

dacbd commented Oct 19, 2022

@tasdomas I think this was caused by file changes to the main.tf,

the original attempt to reproduce with:

#!/bin/bash

dir=$(mktemp -d)
pushd "$dir"
cat <<END >> main.tf
terraform { 
  required_providers { iterative = { source = "iterative/iterative" } }
}
provider "iterative" {}
resource "iterative_task" "test" {
  cloud = "aws"
  machine = "t3.small"
  region = "us-west-1"
  image = "ubuntu"
  disk_size = 10
  storage {
    workdir = "."
    output = "."
  }
  script = <<-SCRIPT
    #!/bin/bash
    echo "hi"
    sleep 300
    echo "done"
  SCRIPT
}
END
for i in {0..9}; do
  dd if=/dev/random of="file_$i.txt" bs=16M count=1 
done

terraform init
terraform apply --auto-approve
terraform apply --auto-approve
terraform destroy --auto-approve
popd && rm -r "$dir"

I was able to reproduce the behavior I saw by editing the main.tf between runs:

#!/bin/bash

dir=$(mktemp -d)
pushd "$dir"
cat <<END >> main.tf
terraform { 
  required_providers { iterative = { source = "iterative/iterative" } }
}
provider "iterative" {}
resource "iterative_task" "test" {
  cloud = "aws"
  machine = "t3.small"
  region = "us-west-1"
  image = "ubuntu"
  disk_size = 10
  storage {
    workdir = "."
    output = "."
  }
  script = <<-SCRIPT
    #!/bin/bash
    echo "hi"
    sleep 300
    echo "done"
  SCRIPT
}
END
for i in {0..9}; do
  dd if=/dev/random of="file_$i.txt" bs=16M count=1 
done

terraform init
terraform apply --auto-approve
cp main.tf ./org.txt
sed -i 's/10/20/g' main.tf
terraform apply --auto-approve
terraform destroy --auto-approve
popd && rm -r "$dir"

If you run the above, you will see the other undesirable behavior

I think this is better solved with a combo of: #590 and #697

@dacbd dacbd closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants