Generate resource, data, variable, output, provider, backend, locals, module, lifecycle and dynamic blocks, each with the thing people get wrong about it.
resource block · 7 lines
The inspector has 2 notes on this block.
Something Terraform creates and manages.
The address is the identity. Renaming a resource makes Terraform destroy and recreate it unless you move the state with a `moved` block.
# Something Terraform creates and manages.
# The address is the identity. Renaming a resource makes Terraform destroy and recreate it unless you move the state with a `moved` block.
resource "aws_s3_bucket" "example" {
bucket = "change-me"
tags = "change-me"
}
What the inspector says about this
No required_version
Without one, whichever version the next person has will run — and a newer version may write a state format older versions cannot read, which blocks everyone else until they upgrade too.
No backend configured, so state is local
Local state lives in one person's working directory, is not locked, and is not backed up. Two people applying at once will corrupt it. A remote backend fixes all three.
A generated sensitive variable is kept required rather than given a default, which is the opposite of what a template generator usually does. A sensitive default is a committed secret, and sensitive = true does nothing about that — it redacts the value from plan output and nothing else; the file still has it and so does the state. Beyond that: no provider schema was consulted, so nothing here knows whether your resource type or its arguments actually exist. terraform validate is what does.
Terraform Block Generator runs entirely on your device — no Terraform command is run, no state is read and no cloud account is contacted.
You’re on the Free plan. Compare plans
A generated sensitive variable is kept required rather than given a default, which is the opposite of what a template generator usually does. A sensitive variable with a default means the default is committed, and `sensitive = true` does nothing about that — it redacts the value from plan output and only from plan output. The file still has it, and so does the state.
Every kind carries its own caution, and these are specific rather than general. A `lifecycle` block with `prevent_destroy` makes `terraform destroy` fail rather than skipping the resource, which is a surprise in a teardown pipeline. A `backend` block cannot use variables or locals at all — it is read before evaluation, so the values must be literals or come from `-backend-config`.
Switching a resource between `count` and `for_each` changes its address, so Terraform plans to destroy and recreate everything unless the state is moved first. That is the kind of thing a generator should mention at the moment you choose between them.
The generated block is run back through the configuration inspector on the page, so you can see what its sibling tool says about it before you paste it anywhere. The two were written separately, which makes the agreement worth something.
Nothing is run. No Terraform, no state, no cloud account.
Because a default is committed, and `sensitive = true` does not change that — it only redacts the value from plan output. A generator that hands you a sensitive variable with a default has handed you a committed secret with a label on it.
Because the backend is configured before Terraform evaluates anything, so there are no variables or locals yet. The values have to be literals, or supplied with `-backend-config` at init. That caution appears when you select the backend block.
Its address changes — `aws_instance.web[0]` becomes `aws_instance.web["a"]` — so Terraform plans to destroy everything and create it again. `terraform state mv` moves them first. The generator says so at the point you pick between them.