Hello, trying to utilize the -lock-timeout option with tf plan, but this option seem to have no impact.
This is what I’ve got:
C:\Training\Terraform>terraform version
Terraform v1.1.2
on windows_386
+ provider registry.terraform.io/hashicorp/aws v3.70.0
main.tf
provider "aws" {
region = "us-east-2"
}
resource "aws_iam_user" "piamec2user" {
name = "pec2user"
}
command sequence
C:\Training\Terraform\>terraform init
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
- Using previously-installed hashicorp/aws v3.70.0
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Have terminals side-by-side, kick-off tf plan simultaneously with -lock-timeout=60s option.
**Terminal #1**
C:\Training\Terraform>terraform plan -lock-timeout=60s
Terraform used the selected providers to generate the following execution plan. Resource
actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_iam_user.piamec2user will be created
+ resource "aws_iam_user" "piamec2user" {
+ arn = (known after apply)
+ force_destroy = false
+ id = (known after apply)
+ name = "pec2user"
+ path = "/"
+ tags_all = (known after apply)
+ unique_id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
───────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take
exactly these actions if you run "terraform apply" now.
**Terminal #2**
C:\Training\Terraform>terraform plan -lock-timeout=60s
╷
│ Error: Error acquiring the state lock
│
│ Error message: Failed to read state file: The state file could not be read: read
│ terraform.tfstate: The process cannot access the file because another process has locked a
│ portion of the file.
│
│ Terraform acquires a state lock to protect the state from being written
│ by multiple users at the same time. Please resolve the issue above and try
│ again. For most commands, you can disable locking with the "-lock=false"
│ flag, but this is not recommended.
Isn’t the -lock-timeout option suppose to keep the session waiting until the one that has a lock completes emitting the plan?
Am I missing anything here… Any leads is much appreciated. TIA!