Reputation: 1
[root@terraform ~]# terraform plan -out terraform.tfstate ╷ │ Error: Error acquiring the state lock │ │ Error message: 2 problems: │ │ - Unsupported state file format: The state file could not be parsed as JSON: │ syntax error at byte offset 1. │ - Unsupported state file format: The state file does not have a "version" │ attribute, which is required to identify the format version. │ │ 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.
Upvotes: 0
Views: 5476
Reputation: 1328
@Ajay Kumar hi, problem is you are trying to pass .tfstate file as input and terraform is not able to parse same. terraform apply command expect .out file or .json file as input. Whereas .tfstate file is one where desired state of your infra is maintained (this is auto created by terraform itself). In this case what you can do is
touch input.tfvars
terraform plan -var-file=input.tfvars -out inputplan.out
$ terraform apply "inputplan.out"
Refer this article for more information
Upvotes: 1