Skip to content

Commit c209a9d

Browse files
Add example of child module outputs in terraform output CLI reference (#1163)
1 parent 5d99b25 commit c209a9d

File tree

14 files changed

+238
-0
lines changed

14 files changed

+238
-0
lines changed

content/terraform/v1.1.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ instance_ips = [
9393
]
9494
```
9595

96+
The `terraform output` command only displays outputs defined in the root module.
97+
To display outputs from child modules, define an `output` block in your
98+
root module using the value of an output from a child module. The example
99+
below uses a child module named `loadbalancer` that defines an output named
100+
`lb_address`. It then defines an output in the root module named `address`
101+
to access the value when you run `terraform output`.
102+
103+
```hcl
104+
module "loadbalancer" {
105+
source = "./modules/loadbalancer"
106+
}
107+
108+
output "address" {
109+
value = module.loadbalancer.lb_address
110+
}
111+
```
112+
96113
## Use in automation
97114

98115
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.10.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@ instance_ips = [
9494
]
9595
```
9696

97+
The `terraform output` command only displays outputs defined in the root module.
98+
To display outputs from child modules, define an `output` block in your
99+
root module using the value of an output from a child module. The example
100+
below uses a child module named `loadbalancer` that defines an output named
101+
`lb_address`. It then defines an output in the root module named `address`
102+
to access the value when you run `terraform output`.
103+
104+
```hcl
105+
module "loadbalancer" {
106+
source = "./modules/loadbalancer"
107+
}
108+
109+
output "address" {
110+
value = module.loadbalancer.lb_address
111+
}
112+
```
113+
97114
## Use in automation
98115

99116
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.11.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ instance_ips = [
9292
]
9393
```
9494

95+
The `terraform output` command only displays outputs defined in the root module.
96+
To display outputs from child modules, define an `output` block in your
97+
root module using the value of an output from a child module. The example
98+
below uses a child module named `loadbalancer` that defines an output named
99+
`lb_address`. It then defines an output in the root module named `address`
100+
to access the value when you run `terraform output`.
101+
102+
```hcl
103+
module "loadbalancer" {
104+
source = "./modules/loadbalancer"
105+
}
106+
107+
output "address" {
108+
value = module.loadbalancer.lb_address
109+
}
110+
```
111+
95112
## Use in automation
96113

97114
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.12.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ instance_ips = [
9292
]
9393
```
9494

95+
The `terraform output` command only displays outputs defined in the root module.
96+
To display outputs from child modules, define an `output` block in your
97+
root module using the value of an output from a child module. The example
98+
below uses a child module named `loadbalancer` that defines an output named
99+
`lb_address`. It then defines an output in the root module named `address`
100+
to access the value when you run `terraform output`.
101+
102+
```hcl
103+
module "loadbalancer" {
104+
source = "./modules/loadbalancer"
105+
}
106+
107+
output "address" {
108+
value = module.loadbalancer.lb_address
109+
}
110+
```
111+
95112
## Use in automation
96113

97114
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.13.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ instance_ips = [
9292
]
9393
```
9494

95+
The `terraform output` command only displays outputs defined in the root module.
96+
To display outputs from child modules, define an `output` block in your
97+
root module using the value of an output from a child module. The example
98+
below uses a child module named `loadbalancer` that defines an output named
99+
`lb_address`. It then defines an output in the root module named `address`
100+
to access the value when you run `terraform output`.
101+
102+
```hcl
103+
module "loadbalancer" {
104+
source = "./modules/loadbalancer"
105+
}
106+
107+
output "address" {
108+
value = module.loadbalancer.lb_address
109+
}
110+
```
111+
95112
## Use in automation
96113

97114
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.14.x (beta)/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ instance_ips = [
9292
]
9393
```
9494

95+
The `terraform output` command only displays outputs defined in the root module.
96+
To display outputs from child modules, define an `output` block in your
97+
root module using the value of an output from a child module. The example
98+
below uses a child module named `loadbalancer` that defines an output named
99+
`lb_address`. It then defines an output in the root module named `address`
100+
to access the value when you run `terraform output`.
101+
102+
```hcl
103+
module "loadbalancer" {
104+
source = "./modules/loadbalancer"
105+
}
106+
107+
output "address" {
108+
value = module.loadbalancer.lb_address
109+
}
110+
```
111+
95112
## Use in automation
96113

97114
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.2.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ instance_ips = [
9393
]
9494
```
9595

96+
The `terraform output` command only displays outputs defined in the root module.
97+
To display outputs from child modules, define an `output` block in your
98+
root module using the value of an output from a child module. The example
99+
below uses a child module named `loadbalancer` that defines an output named
100+
`lb_address`. It then defines an output in the root module named `address`
101+
to access the value when you run `terraform output`.
102+
103+
```hcl
104+
module "loadbalancer" {
105+
source = "./modules/loadbalancer"
106+
}
107+
108+
output "address" {
109+
value = module.loadbalancer.lb_address
110+
}
111+
```
112+
96113
## Use in automation
97114

98115
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.3.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ instance_ips = [
9393
]
9494
```
9595

96+
The `terraform output` command only displays outputs defined in the root module.
97+
To display outputs from child modules, define an `output` block in your
98+
root module using the value of an output from a child module. The example
99+
below uses a child module named `loadbalancer` that defines an output named
100+
`lb_address`. It then defines an output in the root module named `address`
101+
to access the value when you run `terraform output`.
102+
103+
```hcl
104+
module "loadbalancer" {
105+
source = "./modules/loadbalancer"
106+
}
107+
108+
output "address" {
109+
value = module.loadbalancer.lb_address
110+
}
111+
```
112+
96113
## Use in automation
97114

98115
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.4.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ instance_ips = [
9393
]
9494
```
9595

96+
The `terraform output` command only displays outputs defined in the root module.
97+
To display outputs from child modules, define an `output` block in your
98+
root module using the value of an output from a child module. The example
99+
below uses a child module named `loadbalancer` that defines an output named
100+
`lb_address`. It then defines an output in the root module named `address`
101+
to access the value when you run `terraform output`.
102+
103+
```hcl
104+
module "loadbalancer" {
105+
source = "./modules/loadbalancer"
106+
}
107+
108+
output "address" {
109+
value = module.loadbalancer.lb_address
110+
}
111+
```
112+
96113
## Use in automation
97114

98115
The `terraform output` command by default displays in a human-readable format,

content/terraform/v1.5.x/docs/cli/commands/output.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ instance_ips = [
9393
]
9494
```
9595

96+
The `terraform output` command only displays outputs defined in the root module.
97+
To display outputs from child modules, define an `output` block in your
98+
root module using the value of an output from a child module. The example
99+
below uses a child module named `loadbalancer` that defines an output named
100+
`lb_address`. It then defines an output in the root module named `address`
101+
to access the value when you run `terraform output`.
102+
103+
```hcl
104+
module "loadbalancer" {
105+
source = "./modules/loadbalancer"
106+
}
107+
108+
output "address" {
109+
value = module.loadbalancer.lb_address
110+
}
111+
```
112+
96113
## Use in automation
97114

98115
The `terraform output` command by default displays in a human-readable format,

0 commit comments

Comments
 (0)