Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
22a1f70
gathered depends_on content into d_o ref page
trujillo-adam Oct 23, 2025
8ca88ba
draft of depends_on
trujillo-adam Oct 24, 2025
6c39935
revert accidental draft of resources overview
trujillo-adam Oct 24, 2025
c65c4ca
Merge branch 'main' into atru/create-meta-args-reference-topics
trujillo-adam Oct 24, 2025
2f26e85
draft of count, updates to depends_on
trujillo-adam Oct 24, 2025
eb253b1
draft of for_each
trujillo-adam Oct 24, 2025
1a691d5
reorder subtopics on coutn and f_e
trujillo-adam Oct 25, 2025
8091319
draft of provider m-a
trujillo-adam Oct 27, 2025
8f914ae
draft of providers m-a ref
trujillo-adam Oct 27, 2025
17911f6
lifecycle m-a ref draft
trujillo-adam Oct 27, 2025
8b8b8b7
Merge branch 'main' into atru/create-meta-args-reference-topics
trujillo-adam Oct 27, 2025
3f56933
Apply suggestions from code review
trujillo-adam Oct 27, 2025
c78924a
update examples and other tweaks
trujillo-adam Oct 27, 2025
a8193f3
Apply suggestions from code review
trujillo-adam Oct 29, 2025
64c72fc
Merge branch 'main' into atru/create-meta-args-reference-topics
trujillo-adam Oct 29, 2025
6bf58ef
Update content/terraform/v1.13.x/docs/language/meta-arguments/index.mdx
trujillo-adam Oct 29, 2025
2e18a17
Update content/terraform/v1.13.x/docs/language/meta-arguments/lifecyc…
trujillo-adam Oct 29, 2025
1a84bdc
Apply suggestions from code review
trujillo-adam Oct 29, 2025
7148218
Apply suggestions from code review
trujillo-adam Oct 30, 2025
c461d46
Merge branch 'main' into atru/create-meta-args-reference-topics
trujillo-adam Oct 30, 2025
c940b65
backport meta-args topics to 1.12
trujillo-adam Oct 30, 2025
7a29850
forport meta-args topics to 1.14 core - TODO stacks
trujillo-adam Oct 30, 2025
da1b955
link stacks references to m-a refs
trujillo-adam Oct 30, 2025
b371e46
fix merge conflicts
trujillo-adam Oct 30, 2025
fceef78
xlinks from m-a to block refs 1.14
trujillo-adam Oct 30, 2025
cfed737
redir for m-a landing page URL 1.11 and older
trujillo-adam Oct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions content/terraform-docs-common/redirects.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -428,23 +428,7 @@
"permanent": true
},
// Moving meta-arguments content to dedicated meta-arguments reference page
{
"source": "/terraform/language/meta-arguments/:slug",
"destination": "/terraform/language/meta-arguments",
"permanent": true
},
// meta-arguments content pre PR-530 (anything 1.11 and older)
{
"source": "/terraform/language/v:version(1\\.(?:[1-9]|1[01])\\.x)/meta-arguments",
"destination": "/terraform/language/v:version/meta-arguments/depends_on",
"permanent": true
},
// meta-arguments content post PR-530 (anything 1.12 and above)
{
"source": "/terraform/language/v:version((?:1\\.(?:1[2-9]|[2-9]\\d)|[2-9]\\d*\\.\\d+)\\.x)/meta-arguments/:slug",
"destination": "/terraform/language/v:version/meta-arguments",
"permanent": true
},
// temporarily cut redirs to test
// Reference rewrites phase 1 - latest
{
"source": "/terraform/language/providers/configuration",
Expand Down
17 changes: 15 additions & 2 deletions content/terraform/v1.13.x/data/language-nav-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,21 @@
},
{
"title": "Meta-arguments",
"path": "meta-arguments",
"alias": "actions"
"routes": [
{
"title": "Overview",
"path": "meta-arguments",
"alias": "actions"
},
{
"title": "count",
"path": "meta-arguments/count"
},
{
"title": "depends_on",
"path": "meta-arguments/depends_on"
}
]
},
{
"title": "Built-in resources",
Expand Down
34 changes: 5 additions & 29 deletions content/terraform/v1.13.x/docs/language/block/check.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ The `check` block supports the following arguments:
- [`error_message`](#assert)   string
- [`data "<TYPE>" "<LABEL>"`](#data) &nbsp; block
- [`PROVIDER_ARGUMENTS`](#provider_arguments) &nbsp; block | refer to your provider documentation
- [`depends_on`](#depends_on) &nbsp; list of references
- [`provider`](#provider) &nbsp; reference
- [`depends_on`](#depends_on) &nbsp; list of references
- [`provider`](#provider) &nbsp; reference

## Complete configuration

Expand Down Expand Up @@ -122,7 +122,7 @@ The arguments within a `data` block are provider-specific. Refer to the [registr

### `depends_on`

The `depends_on` argument specifies an upstream resource that the `data` block depends on. Terraform must complete all operations on the upstream resource before fetching information from the `data` block.
The `depends_on` argument specifies an upstream resource that the `data` block depends on. Terraform must complete all operations on the upstream resource before fetching information from the `data` block.

```hcl
check "unique_name" {
Expand All @@ -135,13 +135,7 @@ check "unique_name" {
}
```

We recommend adding the `depends_on` argument if your nested data source depends on another resource without referencing that resource directly.

For example, if you define a `check` that verifies that a website API returns `200`, that check fails the first time Terraform runs your configuration because your website's infrastructure does not exist yet. You can set the `depends_on` argument to a resource, such as the load balancer, to ensure Terraform only runs the `check` once the website is up. When running an operation, Terraform evaluates the `check`, warns `known after apply` until that crucial piece of your website is ready, and continues the operation.

However, this strategy only works when the `data` block does not directly reference the resource specified in the `depends_on` argument. Otherwise, anytime that resource changes, the `check` block warns `known after apply` until Terraform updates that resource, making your check potentially noisy and ineffective. Refer to the [example](#resource-dependency) for more details.

The `depends_on` block is a meta-argument. Meta-arguments are built-in arguments that control how Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for additional information.
`depends_on` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`depends_on` reference](/terraform/language/meta-arguments/depends_on) for details about how the argument works.

### `provider`

Expand Down Expand Up @@ -210,22 +204,4 @@ check "service_validation" {
error_message = "Load balancer must have at least one security group"
}
}
```

### Resource dependency

In the following example, Terraform waits to run the check until it creates the `aws_db_instance.main` database. Terraform prints `known after apply`, instead of printing false warnings, until it finishes creating the database:

```hcl
check "database_connection" {
data "postgresql_database" "app_db" {
name = "application"
depends_on = [aws_db_instance.main]
}

assert {
condition = data.postgresql_database.app_db.allow_connections
error_message = "Database is not accepting connections"
}
}
```
```
73 changes: 3 additions & 70 deletions content/terraform/v1.13.x/docs/language/block/data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,16 @@ The provider developer determines which arguments you can define for a data sour

### `count`

The `count` meta-argument instructs Terraform to provision multiple instances of the same data source with identical or similar configuration.
The `count` meta-argument instructs Terraform to provision multiple instances of the same data source with identical or similar configuration. You cannot use both a `count` and ` for_each` argument in the same block.

```hcl
data "<TYPE>" "<LABEL>" {
count = <number>
}
```

You can reference variables or local values and use expressions to compute the value, but the value must resolve to a whole number.
`count` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`count` reference](/terraform/language/meta-arguments/count) for details about how the argument works.

In blocks where `count` is set, Terraform exposes an additional `count` object. You can reference the object to modify the configuration of each instance. The `count` object has an `index` attribute starting from `0`.

To refer to an individual instance of a data source created using the `count` meta-argument, use the `<TYPE>.<NAME>[INDEX]` syntax. For example, `data.aws_instance.server[0]` refers to the first instance of the `aws_instance` data source named `server`.

<Tip>

You can use the `count` argument as a conditional for creating data sources. For example, setting a `count = var.creator ? 3 : 0` instructs Terraform to create three instances of the data source when a variable named `creator` is set to `true`. Refer to [​​Conditional Expressions]/terraform/language/expressions/conditionals) for more information.

</Tip>

The `count` argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.

#### Summary

- Data type: Number.
- Default: None.

### `depends_on`

Expand All @@ -111,21 +95,7 @@ data "<TYPE>" "<LABEL>" {
}
```

When a data source configuration refers to another resource, Terraform identifies the dependency and creates the upstream resource first. In some cases, you may need Terraform to create one resource before creating a data source, even though the resource and the data source are configured independently.

Use the `depends_on` argument when the resource and data source do not reference each other. We recommend always including a comment to explain dependencies when using a `depends_on` argument.

When using the `depends_on` meta-argument, you can only reference other resources or child modules in the same root module. The list cannot include arbitrary expressions. Any values referenced in the `depends_on` list must be known before Terraform begins the operation so that it can evaluate dependencies.

Specifying an entire module in the `depends_on` argument affects the order in which Terraform provisions all of the resources and data sources associated with that module. Refer to [Resource dependencies](/terraform/language/resources/configure#specify-resource-dependencies) and [Data resource dependencies](/terraform/language/resources/configure#specify-resource-dependencies) for more information.

The depends_on argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.

#### Summary

- Data type: List.
- Default: None.
- Example: [Specify a dependency](#specify-a-dependency).
`depends_on` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`depends_on` reference](/terraform/language/meta-arguments/depends_on) for details about how the argument works.

### `for_each`

Expand Down Expand Up @@ -311,43 +281,6 @@ Refer to [Validate your configuration](/terraform/language/validate) for informa

The following examples show how to write configuration for common use cases.

### Specify a dependency

In the following example, Terraform gets an AMI for use in the `aws_instance` resource after creating the `aws_subnet.example_subnet` resource:

```hcl
resource "aws_vpc" "example_vpc" {
cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "example_subnet" {
vpc_id = aws_vpc.example_vpc.id
cidr_block = "10.0.1.0/24"
}

data "aws_ami" "example_ami" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm-*"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
depends_on = [aws_subnet.example_subnet]
}

resource "aws_instance" "example_instance" {
ami = data.aws_ami.example_ami.id
instance_type = "t2.micro"
subnet_id = aws_subnet.example_subnet.id
}
```

Note that this is a simplified example and does not represent a real-world use case. The `depends_on` argument changes the dependency graph so that Terraform creates the resources in a linear order. Without the argument, Terraform would still successfully create the resources.

### Select an alternate provider configuration

In the following example, the `google_compute_instance` data source selects the provider configuration with the `europe` alias.
Expand Down
32 changes: 3 additions & 29 deletions content/terraform/v1.13.x/docs/language/block/ephemeral.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ The provider developer determines which arguments you can define for an ephemera

### `count`

The `count` meta-argument instructs Terraform to provision multiple instances of the same ephemeral resource with identical or similar configuration.
The `count` meta-argument instructs Terraform to provision multiple instances of the same ephemeral resource with identical or similar configuration. You cannot use both a `count` and ` for_each` argument in the same block.

<CodeBlockConfig hideClipboard>

Expand All @@ -131,46 +131,20 @@ ephemeral "<TYPE>" "<LABEL>" {

</CodeBlockConfig>

The value must be a whole number. You can reference variables or local values and use expressions to compute the value, but the value must resolve to a whole number.

In blocks where you set `count`, Terraform exposes an additional `count` object. You can reference the object within the ephemeral block to modify the configuration of each instance. The `count` object has an `index` attribute starting from `0`.

To refer to an individual instance of an ephemeral resource created using the `count` meta-argument, use the `ephemeral.<TYPE>.<LABEL>[INDEX]` syntax. For example, `ephemeral.random_password.db_password[0]` refers to the first instance of the `random_password` ephemeral resource named `db_password`.

The `count` argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.

#### Summary

- Data type: Number
- Default: None
- Example: [Create multiple ephemeral resources](#create-multiple-ephemeral-resources)
`count` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`count` reference](/terraform/language/meta-arguments/count) for details about how the argument works.

### `depends_on`

The `depends_on` meta-argument specifies an upstream resource that the ephemeral resource depends on. When it creates a plan, Terraform sequences all operations on the upstream resource before performing operations on the ephemeral resource configured with the `depends_on` meta-argument.

<CodeBlockConfig hideClipboard>

```hcl
ephemeral "<TYPE>" "<LABEL>" {
depends_on = [ <resource reference> ]
}
```

</CodeBlockConfig>

When an ephemeral resource configuration refers to another resource, Terraform identifies the dependency and creates the upstream resource first. In some cases, you may need Terraform to create a resource before creating an ephemeral resource, even though the resources are configured independently.

Use the `depends_on` argument when the resources do not reference each other. We recommend always including a comment to explain resource dependencies when using a `depends_on` argument.

When using the `depends_on` meta-argument, you can only reference other resources in the same root module or its child modules. The list cannot include arbitrary expressions. Any values referenced in the `depends_on` list must be known before Terraform begins the operation so that it can evaluate dependencies.

The `depends_on` argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.

#### Summary

- Data type: List
- Default: None
`depends_on` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`depends_on` reference](/terraform/language/meta-arguments/depends_on) for details about how the argument works.

### `for_each`

Expand Down
87 changes: 3 additions & 84 deletions content/terraform/v1.13.x/docs/language/block/module.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -398,27 +398,15 @@ Refer to the documentation for the module for versioning mechanisms specific to

### `count`

The `count` meta-argument instructs Terraform to provision multiple instances of the same module with identical or similar configuration.
The `count` meta-argument instructs Terraform to provision multiple instances of the same module with identical or similar configuration. You cannot use both a `count` and ` for_each` argument in the same block.

```hcl
module "<LABEL>" {
count = <number>
}
```

You can reference variables or local values and use expressions to compute the value, but the value must resolve to a whole number.

In blocks where `count` is set, Terraform exposes an additional `count` object. You can reference the object to modify the configuration of each instance. The `count` object has an `index` attribute starting from `0`.

To refer to an individual instance of a module created using the `count` meta-argument, use the `module.<NAME>[INDEX]` syntax. For example, `module.server[0]` refers to the first instance of the module named `server`.

<Tip>

You can use the `count` argument as a conditional for creating modules. For example, setting a `count = var.creator ? 3 : 0` instructs Terraform to create three instances of the module resources when a variable named `creator` is set to `true`. Refer to [​​Conditional Expressions]/terraform/language/expressions/conditionals) for more information.

</Tip>

The `count` argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.
`count` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`count` reference](/terraform/language/meta-arguments/count) for details about how the argument works.

#### Summary

Expand Down Expand Up @@ -525,21 +513,7 @@ module "<LABEL>" {
}
```

When a module configuration refers to another resource, Terraform identifies the dependency and creates the upstream resource first. In some cases, you may need Terraform to create one resource before creating a module, even though the resource and the module are configured independently.

Use the `depends_on` argument when the resource and module do not reference each other. We recommend always including a comment to explain dependencies when using a `depends_on` argument.

When using the `depends_on` meta-argument, you can only reference other resources or child modules in the same root module. The list cannot include arbitrary expressions. Any values referenced in the `depends_on` list must be known before Terraform begins the operation so that it can evaluate dependencies.

Specifying an entire module in the `depends_on` argument affects the order in which Terraform provisions all of the resources and data modules associated with that module. Refer to [Specify resource dependencies](/terraform/language/resources/configure#specify-resource-dependencies) and the [data resource dependencies documentation](/terraform/language/data-sources#dependencies) for more information.

The depends_on argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.

#### Summary

- Data type: List.
- Default: None.
- Example: [Specify a dependency](#specify-a-dependency)
`depends_on` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`depends_on` reference](/terraform/language/meta-arguments/depends_on) for details about how the argument works.

## Examples

Expand Down Expand Up @@ -796,37 +770,6 @@ module "vpc" {

### Create multiple instances of module resources

You can use either `count` or the `for_each` block to create multiple instances of module resources. The `count` argument is most suitable for creating multiple instances that are identical or nearly identical. The `for_each` argument is most suitable for creating multiple instances with varying configuration from a map or set.

<Tabs>

<Tab heading="count">

In the following example, Terraform creates three EC2 instances, each with a unique name from the `instance_names` list:

```hcl
locals {
instance_names = ["example-instance-1", "example-instance-2", "example-instance-3"]
}

module "ec2_instance" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "6.0.2"
count = length(local.instance_names)

name = local.instance_names[count.index]
ami = data.aws_ami.latest_amazon_linux.id
instance_type = "t2.micro"

depends_on = [aws_s3_bucket.example]
}

```

</Tab>

<Tab heading="for_each">

In the following example, Terraform creates one EC2 instance for each key in `local.instance_configs`, allowing you to customize properties per instance:

```hcl
Expand All @@ -852,30 +795,6 @@ module "ec2_instance" {

```

</Tab>

</Tabs>

### Specify dependencies

In the following example, Terraform only creates the EC2 instance module after creating the S3 bucket resource:


```hcl
resource "aws_s3_bucket" "example" {
bucket = "my-example-bucket-12345"
}

module "ec2_instance" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "6.0.2"
name = "example-instance"
ami = data.aws_ami.latest_amazon_linux.id
instance_type = "t2.micro"

depends_on = [aws_s3_bucket.example]
}
```

### Apply different provider configurations for module resources

Expand Down
Loading
Loading