|
| 1 | +--- |
| 2 | +title: "Ignore Resources to be Generated" |
| 3 | +description: "How to ignore resources from generated output" |
| 4 | +menu: |
| 5 | + docs: |
| 6 | + parent: "how-to" |
| 7 | +weight: 204 |
| 8 | +toc: false |
| 9 | +--- |
| 10 | + |
| 11 | +Since `v0.18.0` |
| 12 | + |
| 13 | +Any type of resources can be ignored from the generated output by prepending them |
| 14 | +with a comment `terraform-docs-ignore`. Supported type of Terraform resources to |
| 15 | +get ignored are: |
| 16 | + |
| 17 | +- `resource` |
| 18 | +- `data` |
| 19 | +- `module` |
| 20 | +- `variable` |
| 21 | +- `output` |
| 22 | + |
| 23 | +{{< alert type="info" >}} |
| 24 | +If a `resource` or `data` is ignored, their corresponding discovered provider |
| 25 | +will also get ignored from "Providers" section. |
| 26 | +{{< /alert>}} |
| 27 | + |
| 28 | +Take the following example: |
| 29 | + |
| 30 | +```hcl |
| 31 | +################################################################## |
| 32 | +# All of the following will be ignored from the generated output # |
| 33 | +################################################################## |
| 34 | +
|
| 35 | +# terraform-docs-ignore |
| 36 | +resource "foo_resource" "foo" {} |
| 37 | +
|
| 38 | +# This resource is going to get ignored from generated |
| 39 | +# output by using the following known comment. |
| 40 | +# |
| 41 | +# terraform-docs-ignore |
| 42 | +# |
| 43 | +# The ignore keyword also doesn't have to be the first, |
| 44 | +# last, or the only thing in a leading comment |
| 45 | +resource "bar_resource" "bar" {} |
| 46 | +
|
| 47 | +# terraform-docs-ignore |
| 48 | +data "foo_data_resource" "foo" {} |
| 49 | +
|
| 50 | +# terraform-docs-ignore |
| 51 | +data "bar_data_resource" "bar" {} |
| 52 | +
|
| 53 | +// terraform-docs-ignore |
| 54 | +module "foo" { |
| 55 | + source = "foo" |
| 56 | + version = "x.x.x" |
| 57 | +} |
| 58 | +
|
| 59 | +# terraform-docs-ignore |
| 60 | +variable "foo" { |
| 61 | + default = "foo" |
| 62 | +} |
| 63 | +
|
| 64 | +// terraform-docs-ignore |
| 65 | +output "foo" { |
| 66 | + value = "foo" |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +{{< alert type="info" >}} |
| 71 | +The ignore keyword (i.e. `terraform-docs-ignore`) doesn't have to be the first, |
| 72 | +last, or only thing in a leading comment. As long as the keyword is present in |
| 73 | +a comment, the following resource will get ignored. |
| 74 | +{{< /alert>}} |
0 commit comments