local_file
The resource type from the local provider that creates a file with given content at a given path.
In more detail
It takes filename and content arguments. Changing the content cannot be done in place, so the plan shows a replacement: the file is deleted and written again. As a data source, data.local_file reads an existing file without managing it.
Example
resource "local_file" "greeting" {
filename = "hello.txt"
content = "Hello from Terraform\n"
}Related terms
- local provider — HashiCorp's provider for managing files on the machine where Terraform runs, used throughout the course because it needs no cloud account.
- Terraform resource — A resource block, which asks Terraform to create and manage one piece of infrastructure such as a network, file or database.
- data source — A data block that asks a provider to look up an existing object and return its details, without Terraform creating or owning it.
Taught in
- Installing Terraform And Meeting The CLI — Infrastructure as Code with Terraform
- Providers And The required_providers Block — Infrastructure as Code with Terraform
- Writing Your First Configuration In HCL — Infrastructure as Code with Terraform
- Initialising The Working Directory — Infrastructure as Code with Terraform
- Predicting Changes, Then Applying Them — Infrastructure as Code with Terraform
- Tearing It Down With Destroy — Infrastructure as Code with Terraform
- Parameterising With Input Variables — Infrastructure as Code with Terraform
- Return Values: Outputs And Locals — Infrastructure as Code with Terraform
- Functions And Expressions In HCL — Infrastructure as Code with Terraform
- Querying Existing Infrastructure With Data Sources — Infrastructure as Code with Terraform
- The Plan That Wanted To Destroy Production — HashiCorp Terraform Associate (004) Exam Prep
- Providers: How Terraform Reaches Every API — HashiCorp Terraform Associate (004) Exam Prep
- Validate, Format, Destroy, And The Flags That Bend A Plan — HashiCorp Terraform Associate (004) Exam Prep
- Resources, Data Sources And The References Between Them — HashiCorp Terraform Associate (004) Exam Prep
- Expressions And Functions: Making Configuration Compute — HashiCorp Terraform Associate (004) Exam Prep
- Count, For Each And Dynamic Blocks — HashiCorp Terraform Associate (004) Exam Prep
- Dependencies, depends_on And Lifecycle Rules — HashiCorp Terraform Associate (004) Exam Prep
- Custom Conditions: Validation, Pre And Postconditions, Checks — HashiCorp Terraform Associate (004) Exam Prep