Skip to content

Avoid using the deprecated -state flag in the terraform plan command #202

@minamijoyo

Description

@minamijoyo

The terraform plan -state flag has been deprecated since Terraform v1.10. hashicorp/terraform#35660

I knew this flag was meaningless for remote backends, but it works for local backends. However, we should avoid using it as we get a deprecation warning in Terraform v.1.10+.

There are two possible ways to implement this. we can use the terraform state command on the temporary tfstate as before, but just before executing the terraform plan on the final phase, do the following additionally:

(1) Set the path attribute of the local backend in the override file to the temporary tfstate file and execute terraform init.
(2) Copy the temporary tfstate file to terraform.tfstate, which is the default value of the path attribute, and delete it after the terraform plan.

The latter may be simpler to design, but ensure the tfstate file must be deleted even if errors occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions