Skip to content

Commit 63300d5

Browse files
committed
feat!: introduced provider config next to provider_meta config
Renamed seed_prefix to guid_seed_addition to clarify its purpose. Renamed unique_seed to guid_seed to clarify that it needs to be globally unique per resource type. Added per-resource-type uniqueness.
1 parent 07f85af commit 63300d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+684
-636
lines changed

docs/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ description: |-
1414

1515
<!-- schema generated by tfplugindocs -->
1616
## Schema
17+
18+
### Optional
19+
20+
- `guid_seed_addition` (String) It serves as addition to each seed of any `value_is_fully_known` (resource) or `value_is_known` (resource) within the project if specified in provider, or within the same module if specified in provider-meta.
21+
22+
**Placeholders**:
23+
- "{workdir}" (Keyword) The actual workdir; equals to terraform's path.root. This placeholder is
24+
recommended because this value won't be dragged along the plan and apply phase in comparison to
25+
"abspath(path.root)" that you would add to resource seed where a change to path.root would be
26+
recognized just as usual from terraform.

docs/resources/is_fully_known.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ subcategory: ""
55
description: |-
66
Allows you to have a access to result during plan phase that states whether value or any nested attribute is marked as "(known after apply)" or not.
77
Provider Metadata
8-
Each module can use provider_meta. Please keep in mind that these settings only count for resources of this module! (see https://www.terraform.io/internals/provider-meta):
9-
terraform
10-
// Terraform provider_meta example
11-
terraform {
12-
// "value" is the provider name
13-
provider_meta "value" {
14-
// {workdir} -> The only available placeholder currently (see below for more information)
15-
seed_prefix = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
8+
Each module can use providermeta. Please keep in mind that these settings only count for resources of this module! (see https://www.terraform.io/internals/provider-meta https://www.terraform.io/internals/provider-meta):
9+
```terraform
10+
// Terraform providermeta example
11+
terraform {
12+
// "value" is the provider name
13+
providermeta "value" {
14+
// {workdir} -> The only available placeholder currently (see below for more information)
15+
guidseed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
16+
}
1617
}
17-
}
18-
18+
```
1919
Optional
20-
seed_prefix (String) It gets appended to each seed of any value_is_fully_known (resource) or value_is_known (resource) within the same module.
20+
guid_seed_addition (String) It serves as addition to each seed of any value_is_fully_known (resource) or value_is_known (resource) within the project if specified in provider, or within the same module if specified in provider-meta.
2121
Placeholders:
2222
"{workdir}" (Keyword) The actual workdir; equals to terraform's path.root. This placeholder is
2323
recommended because this value won't be dragged along the plan and apply phase in comparison to
@@ -29,19 +29,19 @@ description: |-
2929

3030
Allows you to have a access to `result` during plan phase that states whether `value` or any nested attribute is marked as "(known after apply)" or not.
3131
## Provider Metadata
32-
Each module can use provider_meta. Please keep in mind that these settings only count for resources of this module! (see https://www.terraform.io/internals/provider-meta):
32+
Each module can use provider_meta. Please keep in mind that these settings only count for resources of this module! (see [https://www.terraform.io/internals/provider-meta](https://www.terraform.io/internals/provider-meta)):
3333
```terraform
3434
// Terraform provider_meta example
35-
terraform {
36-
// "value" is the provider name
37-
provider_meta "value" {
38-
// {workdir} -> The only available placeholder currently (see below for more information)
39-
seed_prefix = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
35+
terraform {
36+
// "value" is the provider name
37+
provider_meta "value" {
38+
// {workdir} -> The only available placeholder currently (see below for more information)
39+
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
40+
}
4041
}
41-
}
4242
```
4343
### Optional
44-
- `seed_prefix` (String) It gets appended to each seed of any `value_is_fully_known` (resource) or `value_is_known` (resource) within the same module.
44+
- `guid_seed_addition` (String) It serves as addition to each seed of any `value_is_fully_known` (resource) or `value_is_known` (resource) within the project if specified in provider, or within the same module if specified in provider-meta.
4545

4646
**Placeholders**:
4747
- "{workdir}" (Keyword) The actual workdir; equals to terraform's path.root. This placeholder is
@@ -56,8 +56,8 @@ terraform {
5656

5757
### Required
5858

59+
- `guid_seed` (String) Attention! The seed is being used to determine resource uniqueness prior (first plan phase) and during apply phase (second plan phase). Very important to state is that the **seed must be fully known during the plan phase**, otherwise, an error is thrown. Within one terraform plan & apply the **seed of every "value_is_fully_known" must be unique**! I really recommend you to use the provider configuration and/or provider_meta configuration to increase resource uniqueness. Besides `guid_seed`, the provider configuration seed, the provider_meta configuration seed and the resource type itself will become part of the final seed. Under certain circumstances you may face problems if you run terraform concurrenctly. If you do so, then I recommend you to pass-through a random value via a user (environment) variable that you then add to the seed.
5960
- `proposed_unknown` (Dynamic) It is very crucial that this field is **not** filled by any custom value except the one produced by `value_unknown_proposer` (resource). This has the reason as its `value` is **always** unknown during the plan phase. On this behaviour this resource must rely and it cannot check if you do not so!
60-
- `unique_seed` (String) Attention! The seed is being used to determine resource uniqueness prior and during apply-phase. Very important to state is that the **seed must be fully known during the plan phase**, otherwise, an error is thrown. Within one terraform plan & apply the **seed of every "value_is_fully_known" must be unique**! I recommend you to use the provider_meta-feature for increased uniqueness. Under certain circumstances you may face problems if you run terraform concurrenctly. If you do so, then I recommend you to pass-through a random value via a user (environment) variable that you then add to the seed.
6161
- `value` (Dynamic) The `value` and if existing, nested attributes, are tested against "(known after apply)"
6262

6363
### Optional

docs/resources/is_known.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ subcategory: ""
55
description: |-
66
Allows you to have a access to result during plan phase that states whether value marked as "(known after apply)" or not.
77
Provider Metadata
8-
Each module can use provider_meta. Please keep in mind that these settings only count for resources of this module! (see https://www.terraform.io/internals/provider-meta):
9-
terraform
10-
// Terraform provider_meta example
11-
terraform {
12-
// "value" is the provider name
13-
provider_meta "value" {
14-
// {workdir} -> The only available placeholder currently (see below for more information)
15-
seed_prefix = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
8+
Each module can use providermeta. Please keep in mind that these settings only count for resources of this module! (see https://www.terraform.io/internals/provider-meta https://www.terraform.io/internals/provider-meta):
9+
```terraform
10+
// Terraform providermeta example
11+
terraform {
12+
// "value" is the provider name
13+
providermeta "value" {
14+
// {workdir} -> The only available placeholder currently (see below for more information)
15+
guidseed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
16+
}
1617
}
17-
}
18-
18+
```
1919
Optional
20-
seed_prefix (String) It gets appended to each seed of any value_is_fully_known (resource) or value_is_known (resource) within the same module.
20+
guid_seed_addition (String) It serves as addition to each seed of any value_is_fully_known (resource) or value_is_known (resource) within the project if specified in provider, or within the same module if specified in provider-meta.
2121
Placeholders:
2222
"{workdir}" (Keyword) The actual workdir; equals to terraform's path.root. This placeholder is
2323
recommended because this value won't be dragged along the plan and apply phase in comparison to
@@ -29,19 +29,19 @@ description: |-
2929

3030
Allows you to have a access to `result` during plan phase that states whether `value` marked as "(known after apply)" or not.
3131
## Provider Metadata
32-
Each module can use provider_meta. Please keep in mind that these settings only count for resources of this module! (see https://www.terraform.io/internals/provider-meta):
32+
Each module can use provider_meta. Please keep in mind that these settings only count for resources of this module! (see [https://www.terraform.io/internals/provider-meta](https://www.terraform.io/internals/provider-meta)):
3333
```terraform
3434
// Terraform provider_meta example
35-
terraform {
36-
// "value" is the provider name
37-
provider_meta "value" {
38-
// {workdir} -> The only available placeholder currently (see below for more information)
39-
seed_prefix = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
35+
terraform {
36+
// "value" is the provider name
37+
provider_meta "value" {
38+
// {workdir} -> The only available placeholder currently (see below for more information)
39+
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
40+
}
4041
}
41-
}
4242
```
4343
### Optional
44-
- `seed_prefix` (String) It gets appended to each seed of any `value_is_fully_known` (resource) or `value_is_known` (resource) within the same module.
44+
- `guid_seed_addition` (String) It serves as addition to each seed of any `value_is_fully_known` (resource) or `value_is_known` (resource) within the project if specified in provider, or within the same module if specified in provider-meta.
4545

4646
**Placeholders**:
4747
- "{workdir}" (Keyword) The actual workdir; equals to terraform's path.root. This placeholder is
@@ -56,8 +56,8 @@ terraform {
5656

5757
### Required
5858

59+
- `guid_seed` (String) Attention! The seed is being used to determine resource uniqueness prior (first plan phase) and during apply phase (second plan phase). Very important to state is that the **seed must be fully known during the plan phase**, otherwise, an error is thrown. Within one terraform plan & apply the **seed of every "value_is_known" must be unique**! I really recommend you to use the provider configuration and/or provider_meta configuration to increase resource uniqueness. Besides `guid_seed`, the provider configuration seed, the provider_meta configuration seed and the resource type itself will become part of the final seed. Under certain circumstances you may face problems if you run terraform concurrenctly. If you do so, then I recommend you to pass-through a random value via a user (environment) variable that you then add to the seed.
5960
- `proposed_unknown` (Dynamic) It is very crucial that this field is **not** filled by any custom value except the one produced by `value_unknown_proposer` (resource). This has the reason as its `value` is **always** unknown during the plan phase. On this behaviour this resource must rely and it cannot check if you do not so!
60-
- `unique_seed` (String) Attention! The seed is being used to determine resource uniqueness prior and during apply-phase. Very important to state is that the **seed must be fully known during the plan phase**, otherwise, an error is thrown. Within one terraform plan & apply the **seed of every "value_is_known" must be unique**! I recommend you to use the provider_meta-feature for increased uniqueness. Under certain circumstances you may face problems if you run terraform concurrenctly. If you do so, then I recommend you to pass-through a random value via a user (environment) variable that you then add to the seed.
6161
- `value` (Dynamic) The `value` (not nested attributes) is test against "(known after apply)"
6262

6363
### Optional

examples/is_fully_known/provider_meta.tf

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/is_fully_known/shared.tf

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
terraform {
2+
required_providers {
3+
value = {
4+
source = "github.com/pseudo-dynamic/value"
5+
version = "0.1.0"
6+
}
7+
}
8+
9+
provider_meta "value" {
10+
// Module-scoped seed addition.
11+
// {workdir} -> a placeholder (see docs)
12+
guid_seed_addition = "module(is-fully-known)"
13+
}
14+
}
15+
16+
provider "value" {
17+
// Project-wide seed addition.
18+
// Won't overwrite module-scoped seed addition,
19+
// instead both serve are now considered as seed addition.
20+
guid_seed_addition = "{workdir}"
21+
}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
// This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!
1+
// This example is complete but there are additional features implemented in terraform.tf!
2+
3+
resource "value_unknown_proposer" "known" {}
24

35
resource "value_is_fully_known" "known" {
46
value = "test"
5-
unique_seed = "known"
6-
proposed_unknown = value_unknown_proposer.default.value
7+
guid_seed = "known"
8+
proposed_unknown = value_unknown_proposer.known.value
79
}
810

911
output "is_known_value" {
1012
value = {
11-
is_fully_known = value_is_fully_known.known.result
13+
fully_known = value_is_fully_known.known.result
1214
}
13-
}
15+
}

examples/is_fully_known/test_known_with_nested_unknown.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
// This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!
1+
// This example is complete but there are additional features implemented in terraform.tf!
2+
3+
resource "value_unknown_proposer" "known_with_nested_unknown" {}
4+
5+
resource "value_promise" "known_with_nested_unknown" {
6+
value = "test"
7+
}
28

39
resource "value_is_fully_known" "known_with_nested_unknown" {
410
value = {
5-
nested = value_promise.default.result
11+
nested = value_promise.known_with_nested_unknown.result
612
}
713

8-
unique_seed = "nested_known"
9-
proposed_unknown = value_unknown_proposer.default.value
14+
guid_seed = "nested_unknown"
15+
proposed_unknown = value_unknown_proposer.known_with_nested_unknown.value
1016
}
1117

1218
output "is_known_with_nested_unknown_value" {
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
// This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!
1+
// This example is complete but there are additional features implemented in terraform.tf!
2+
3+
resource "value_unknown_proposer" "unknown" {}
4+
5+
resource "value_promise" "unknown" {
6+
value = "test"
7+
}
28

39
resource "value_is_fully_known" "unknown" {
4-
value = value_promise.default.result
5-
unique_seed = "unknown"
6-
proposed_unknown = value_unknown_proposer.default.value
10+
value = value_promise.unknown.result
11+
guid_seed = "unknown"
12+
proposed_unknown = value_unknown_proposer.unknown.value
713
}
814

915
output "is_unknown_value" {
1016
value = {
11-
is_fully_known = value_is_fully_known.unknown.result
17+
fully_known = value_is_fully_known.unknown.result
1218
}
1319
}

examples/is_known/provider_meta.tf

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)