hashicorp / terraform-provider-local

Utility provider used to manage local resources, such as creating files.
https://registry.terraform.io/providers/hashicorp/local/latest
Mozilla Public License 2.0
213 stars 66 forks source link

`function/direxists`: Add function that checks if a directory exists #285

Closed austinvalle closed 7 months ago

austinvalle commented 9 months ago

Ref: https://github.com/hashicorp/terraform/issues/33394, https://github.com/hashicorp/terraform/issues/25316, https://github.com/hashicorp/terraform/pull/29996

This PR introduces a new provide-defined function for checking the existence of a directory on the filesystem running Terraform. Similar to fileexists.

terraform {
  required_providers {
    local = {
      source = "hashicorp/local"
    }
  }
  required_version = ">= 1.8.0"
}

output "example_output" {
  value = provider::local::direxists("${path.module}/example-directory")
}
 $ tree          
.
├── example-directory
└── function.tf

2 directories, 1 file

 $ terraform plan

Changes to Outputs:
  + example_output = true

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.

Notes

bflad commented 9 months ago

terraform-plugin-docs is now updated on main 👍

github-actions[bot] commented 5 months ago

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.