{"id":13451697,"url":"https://github.com/sethvargo/terraform-provider-filesystem","last_synced_at":"2025-04-08T04:16:46.858Z","repository":{"id":46573766,"uuid":"132665883","full_name":"sethvargo/terraform-provider-filesystem","owner":"sethvargo","description":"A @HashiCorp Terraform provider for interacting with the filesystem","archived":false,"fork":false,"pushed_at":"2025-03-13T00:26:36.000Z","size":9034,"stargazers_count":61,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-30T13:41:40.424Z","etag":null,"topics":["hashicorp","terraform","terraform-provider"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sethvargo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-08T21:13:16.000Z","updated_at":"2024-10-18T18:17:03.000Z","dependencies_parsed_at":"2023-01-31T19:50:11.900Z","dependency_job_id":"7c03f684-58ee-4190-bf1e-513934754df8","html_url":"https://github.com/sethvargo/terraform-provider-filesystem","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sethvargo%2Fterraform-provider-filesystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sethvargo%2Fterraform-provider-filesystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sethvargo%2Fterraform-provider-filesystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sethvargo%2Fterraform-provider-filesystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sethvargo","download_url":"https://codeload.github.com/sethvargo/terraform-provider-filesystem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773721,"owners_count":20993639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hashicorp","terraform","terraform-provider"],"created_at":"2024-07-31T07:00:59.406Z","updated_at":"2025-04-08T04:16:46.830Z","avatar_url":"https://github.com/sethvargo.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Terraform FileSystem Provider\n\nThis is a [Terraform][terraform] provider for managing the local filesystem with\nTerraform. It enables you to treat \"files as code\" the same way you already\ntreat infrastructure as code!\n\n\n## Installation\n\n1. Download the latest compiled binary from [GitHub releases][releases].\n\n1. Untar the archive.\n\n1. Move it into `$HOME/.terraform.d/plugins`:\n\n    ```sh\n    $ mkdir -p $HOME/.terraform.d/plugins\n    $ mv terraform-provider-filesystem $HOME/.terraform.d/plugins/terraform-provider-filesystem\n    ```\n\n1. Create your Terraform configurations as normal, and run `terraform init`:\n\n    ```sh\n    $ terraform init\n    ```\n\n    This will find the plugin locally.\n\n\n## Usage\n\n1. Create a Terraform configuration file:\n\n    ```hcl\n    resource \"filesystem_file_writer\" \"example\" {\n      path     = \"file.txt\"\n      contents = \"hello world\"\n    }\n\n    resource \"filesystem_file_reader\" \"example\" {\n      path = \"${filesystem_file_writer.example.path}\"\n    }\n    ```\n\n1. Run `terraform init` to pull in the provider:\n\n    ```sh\n    $ terraform init\n    ```\n\n1. Run `terraform plan` and `terraform apply` to interact with the filesystem:\n\n    ```sh\n    $ terraform plan\n\n    $ terraform apply\n    ```\n\n## Examples\n\nFor more examples, please see the [examples][examples] folder in this\nrepository.\n\n## Reference\n\n### Filesystem Reader\n\n#### Usage\n\n```hcl\nresource \"filesystem_file_reader\" \"read\" {\n  path = \"my-file.txt\"\n}\n```\n\n#### Arguments\n\nArguments are provided as inputs to the resource, in the `*.tf` file.\n\n- `path` `(string, required)` - the path to the file on disk.\n\n- `root` `(string: $CWD)` - the root of the Terraform configurations. By\n  default, this will be the current working directory. If you're running\n  Terraform against configurations outside of the working directory (like\n  `terraform apply ../../foo`), set this value to `${path.module}`.\n\n#### Attributes\n\nAttributes are values that are only known after creation.\n\n- `contents` `(string)` - the contents of the file as a string. Contents are\n  converted to a string, so it is not recommended you use this resource on\n  binary files.\n\n- `name` `(string)` - the name of the file.\n\n- `size` `(int)` - the size of the file in bytes.\n\n- `mode` `(int)` - the permissions on the file in octal.\n\n\n### Filesystem Writer\n\n#### Usage\n\n```hcl\nresource \"filesystem_file_writer\" \"write\" {\n  path     = \"my-file.txt\"\n  contents = \"hello world!\"\n}\n```\n\n#### Arguments\n\n- `path` `(string, required)` - the path to the file on disk.\n\n- `contents` `(string, required)` - the contents of the file as a string.\n\n- `root` `(string: $CWD)` - the root of the Terraform configurations. By\n  default, this will be the current working directory. If you're running\n  Terraform against configurations outside of the working directory (like\n  `terraform apply ../../foo`), set this value to `${path.module}`.\n\n- `create_parent_dirs` `(bool: true)` - create parent directories if they do not\n  exist. By default, this is true. If set to false, the parent directories of\n  the file must exist or this resource will error.\n\n- `delete_on_destroy` `(bool: true)` - delete this file on destroy. Set this to\n  false and Terraform will leave the file on disk on `terraform destroy`.\n\n- `mode` `(int)` - the permissions on the file in octal.\n\n#### Attributes\n\n- `name` `(string)` - the name of the file.\n\n- `size` `(int)` - the size of the file in bytes.\n\n## FAQ\n\n**Q: How is this different than the built-in `${file()}` function?**\u003cbr\u003e\nA: The built-in `file` function resolves paths and files at compile time. This\nmeans the file must exist before Terraform can begin executing. In some\nsituations, the Terraform run itself may create files, but they will not exist\nat start time. This Terraform provider enables you to treat files just like\nother cloud resources, resolving them at runtime. This allows you to read and\nwrite files from other sources without worrying about dependency ordering.\n\n**Q: How is this different than [terraform-provider-local][terraform-provider-local]?**\u003cbr\u003e\nA: There are quite a few differences:\n\n1. The equivalent \"reader\" is a data source. Data sources are resolved before\nresources run, meaning it is not possible to use the data source to read a file\nthat is created _during_ the terraform run. Terraform will fail early that it\ncould not read the file. This provider specifically addresses that challenge by\nusing a resource instead of a data source.\n\n1. The equivalent \"reader\" does not expose all the fields of the stat file (like\nmode and owner permissions).\n\n1. The equivalent \"writer\" does not allow setting file permissions, controlling\nparent directory creation, or controlling deletion behavior. Additionally, as a\n**super ultra bad thing**, the file permissions are written as 0777 (globally\nexecutable), leaving a large security loophole.\n\n1. The equivalent \"writer\" does not use an atomic file write. For large file\nchunks, this can result in a partially committed file and/or improper\npermissions that compromise security.\n\n1. Neither the equivalent \"reader\" nor the \"writer\" limit the size of the file\nbeing read/written. This poses a security threat as an attacker could overflow\nthe process (think about Terraform running arbitrary configuration as a hosted\nservice).\n\n1. The terraform-provider-local stores the full path of the file in the state,\nrendering the configurations un-portable. This provider calculates the filepath\nrelative to the Terraform module, allowing for more flexibility.\n\n**Q: Is it secure?**\u003cbr\u003e\nA: The contents of files written and read are stored **in plain text** in the\nstatefile. They are marked as sensitive in the output, but they will still be\nstored in the state. This is required in order for other resources to be able to\nread the values. If you are using these resources with sensitive data, you\nshould encrypt your state using [remote state][remote-state].\n\n## License \u0026 Author\n\n```\nCopyright 2018 Google, Inc.\nCopyright 2018 Seth Vargo\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n[terraform]: https://www.terraform.io/\n[releases]: https://github.com/sethvargo/terraform-provider-filesystem/releases\n[examples]: https://github.com/sethvargo/terraform-provider-filesystem/tree/master/examples\n[remote-state]: https://www.terraform.io/docs/state/remote.html\n[terraform-provider-local]: https://github.com/terraform-providers/terraform-provider-local\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsethvargo%2Fterraform-provider-filesystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsethvargo%2Fterraform-provider-filesystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsethvargo%2Fterraform-provider-filesystem/lists"}