Skip to content

remove empty state files after all infrastructure is destroyed #26323

@scott-doyland-burrows

Description

@scott-doyland-burrows

Current Terraform Version

0.13.2

Use-cases

We deploy IaC via Azure DevOps pipelines. Each of our deploys is based off a pull request number. Both the infrastructure and terraform statefiles have the PR number in the name, eg a terraform statefile would be named:

$(project).$(PRnumber).terraform.tfstate

The infrastructure is destroyed once the PR is complete. However terraform leave a 156byte statefile in place on the Azure backend blob storage.

Could terraform be altered to delete the statefile if it is empty (ie if it has no infrastructure defined in it).

Currently we end up with hundreds of tiny 156byte statefiles that we have to delete outside of terraform.

Thanks,
Scott

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions