Skip to content

Commit a5b1aab

Browse files
committed
docs(provider): Split the examples for env_ensure into separate code blocks.
1 parent b163ca6 commit a5b1aab

File tree

7 files changed

+152
-43
lines changed

7 files changed

+152
-43
lines changed

docs/data-sources/env_ensure.md

+46
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Maps to the [`corefunc.EnvEnsure()`](https://pkg.go.dev/github.com/northwood-lab
3131

3232
## Example Usage
3333

34+
### `AWS_DEFAULT_REGION` is defined (no error)
35+
3436
```terraform
3537
#-------------------------------------------------------------------------
3638
# AWS_DEFAULT_REGION="us-east-1"
@@ -46,7 +48,11 @@ output "aws_default_region_value" {
4648
}
4749
4850
#=> us-east-1
51+
```
52+
53+
### `AWS_PAGER` is set to an empty string (error)
4954

55+
```terraform
5056
#-------------------------------------------------------------------------
5157
# AWS_PAGER=""
5258
@@ -60,7 +66,11 @@ output "aws_pager_value" {
6066
6167
#=> [Error] Problem with Environment Variable: environment variable
6268
#=> AWS_PAGER is not defined
69+
```
70+
71+
### `AWS_VAULT` is defined, but does not match pattern (error)
6372

73+
```terraform
6474
#-------------------------------------------------------------------------
6575
# AWS_VAULT="dev"
6676
@@ -77,6 +87,42 @@ output "aws_vault_value" {
7787
#=> AWS_VAULT does not match pattern (non)?prod$
7888
```
7989

90+
### Example plan output
91+
92+
```bash
93+
AWS_DEFAULT_REGION="us-east-1" AWS_VAULT="dev" terraform plan
94+
```
95+
96+
```plain
97+
data.corefunc_env_ensure.aws_vault: Reading...
98+
data.corefunc_env_ensure.aws_pager: Reading...
99+
data.corefunc_env_ensure.aws_default_region: Reading...
100+
data.corefunc_env_ensure.aws_default_region: Read complete after 0s [name=AWS_DEFAULT_REGION]
101+
102+
Changes to Outputs:
103+
+ aws_default_region_value = "us-east-1"
104+
105+
You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
106+
107+
│ Error: Problem with Environment Variable
108+
109+
│ with data.corefunc_env_ensure.aws_pager,
110+
│ on data-source-AWS_PAGER.tf line 4, in data "corefunc_env_ensure" "aws_pager":
111+
│ 4: data "corefunc_env_ensure" "aws_pager" {
112+
113+
│ environment variable AWS_PAGER is not defined
114+
115+
116+
│ Error: Problem with Environment Variable
117+
118+
│ with data.corefunc_env_ensure.aws_vault,
119+
│ on data-source-AWS_VAULT.tf line 4, in data "corefunc_env_ensure" "aws_vault":
120+
│ 4: data "corefunc_env_ensure" "aws_vault" {
121+
122+
│ environment variable AWS_VAULT does not match pattern (non)?prod$
123+
124+
```
125+
80126
<!-- schema generated by tfplugindocs -->
81127
## Schema
82128

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#-------------------------------------------------------------------------
2+
# AWS_DEFAULT_REGION="us-east-1"
3+
4+
data "corefunc_env_ensure" "aws_default_region" {
5+
name = "AWS_DEFAULT_REGION"
6+
}
7+
8+
# `aws_default_region_value` is the read-only attribute containing the
9+
# value of the environment variable
10+
output "aws_default_region_value" {
11+
value = data.corefunc_env_ensure.aws_default_region.value
12+
}
13+
14+
#=> us-east-1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#-------------------------------------------------------------------------
2+
# AWS_PAGER=""
3+
4+
data "corefunc_env_ensure" "aws_pager" {
5+
name = "AWS_PAGER"
6+
}
7+
8+
output "aws_pager_value" {
9+
value = data.corefunc_env_ensure.aws_pager.value
10+
}
11+
12+
#=> [Error] Problem with Environment Variable: environment variable
13+
#=> AWS_PAGER is not defined
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#-------------------------------------------------------------------------
2+
# AWS_VAULT="dev"
3+
4+
data "corefunc_env_ensure" "aws_vault" {
5+
name = "AWS_VAULT"
6+
pattern = "(non)?prod$" # Must end with "prod" or "nonprod".
7+
}
8+
9+
output "aws_vault_value" {
10+
value = data.corefunc_env_ensure.aws_vault.value
11+
}
12+
13+
#=> [Error] Problem with Environment Variable: environment variable
14+
#=> AWS_VAULT does not match pattern (non)?prod$

examples/data-sources/corefunc_env_ensure/data-source.tf

-43
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
data.corefunc_env_ensure.aws_vault: Reading...
2+
data.corefunc_env_ensure.aws_pager: Reading...
3+
data.corefunc_env_ensure.aws_default_region: Reading...
4+
data.corefunc_env_ensure.aws_default_region: Read complete after 0s [name=AWS_DEFAULT_REGION]
5+
6+
Changes to Outputs:
7+
+ aws_default_region_value = "us-east-1"
8+
9+
You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
10+
11+
│ Error: Problem with Environment Variable
12+
13+
│ with data.corefunc_env_ensure.aws_pager,
14+
│ on data-source-AWS_PAGER.tf line 4, in data "corefunc_env_ensure" "aws_pager":
15+
│ 4: data "corefunc_env_ensure" "aws_pager" {
16+
17+
│ environment variable AWS_PAGER is not defined
18+
19+
20+
│ Error: Problem with Environment Variable
21+
22+
│ with data.corefunc_env_ensure.aws_vault,
23+
│ on data-source-AWS_VAULT.tf line 4, in data "corefunc_env_ensure" "aws_vault":
24+
│ 4: data "corefunc_env_ensure" "aws_vault" {
25+
26+
│ environment variable AWS_VAULT does not match pattern (non)?prod$
27+
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--
2+
---
3+
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
4+
subcategory: ""
5+
description: |-
6+
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
7+
---
8+
-->
9+
10+
# {{.Name}} ({{.Type}})
11+
12+
{{ .Description | trimspace }}
13+
14+
## Example Usage
15+
16+
### `AWS_DEFAULT_REGION` is defined (no error)
17+
18+
{{ tffile "examples/data-sources/corefunc_env_ensure/data-source.AWS_DEFAULT_REGION.tf" }}
19+
20+
### `AWS_PAGER` is set to an empty string (error)
21+
22+
{{ tffile "examples/data-sources/corefunc_env_ensure/data-source.AWS_PAGER.tf" }}
23+
24+
### `AWS_VAULT` is defined, but does not match pattern (error)
25+
26+
{{ tffile "examples/data-sources/corefunc_env_ensure/data-source.AWS_VAULT.tf" }}
27+
28+
### Example plan output
29+
30+
```bash
31+
AWS_DEFAULT_REGION="us-east-1" AWS_VAULT="dev" terraform plan
32+
```
33+
34+
{{ codefile "plain" "examples/data-sources/corefunc_env_ensure/terraform-plan.example" }}
35+
36+
{{ .SchemaMarkdown | trimspace }}
37+
38+
<!-- Preview the provider docs with the Terraform registry provider docs preview tool: https://registry.terraform.io/tools/doc-preview -->

0 commit comments

Comments
 (0)