Skip to content

Commit

Permalink
feat!: introduced provider config next to provider_meta config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
teneko committed Sep 19, 2022
1 parent 07f85af commit 63300d5
Show file tree
Hide file tree
Showing 51 changed files with 684 additions and 636 deletions.
10 changes: 10 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ description: |-

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `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.

**Placeholders**:
- "{workdir}" (Keyword) The actual workdir; equals to terraform's path.root. This placeholder is
recommended because this value won't be dragged along the plan and apply phase in comparison to
"abspath(path.root)" that you would add to resource seed where a change to path.root would be
recognized just as usual from terraform.
40 changes: 20 additions & 20 deletions docs/resources/is_fully_known.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ subcategory: ""
description: |-
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.
Provider Metadata
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):
terraform
// Terraform provider_meta example
terraform {
// "value" is the provider name
provider_meta "value" {
// {workdir} -> The only available placeholder currently (see below for more information)
seed_prefix = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
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):
```terraform
// Terraform providermeta example
terraform {
// "value" is the provider name
providermeta "value" {
// {workdir} -> The only available placeholder currently (see below for more information)
guidseed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
}
}
}
```
Optional
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.
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.
Placeholders:
"{workdir}" (Keyword) The actual workdir; equals to terraform's path.root. This placeholder is
recommended because this value won't be dragged along the plan and apply phase in comparison to
Expand All @@ -29,19 +29,19 @@ description: |-

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.
## Provider Metadata
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):
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)):
```terraform
// Terraform provider_meta example
terraform {
// "value" is the provider name
provider_meta "value" {
// {workdir} -> The only available placeholder currently (see below for more information)
seed_prefix = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
terraform {
// "value" is the provider name
provider_meta "value" {
// {workdir} -> The only available placeholder currently (see below for more information)
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
}
}
}
```
### Optional
- `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.
- `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.

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

### Required

- `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.
- `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!
- `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.
- `value` (Dynamic) The `value` and if existing, nested attributes, are tested against "(known after apply)"

### Optional
Expand Down
40 changes: 20 additions & 20 deletions docs/resources/is_known.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ subcategory: ""
description: |-
Allows you to have a access to result during plan phase that states whether value marked as "(known after apply)" or not.
Provider Metadata
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):
terraform
// Terraform provider_meta example
terraform {
// "value" is the provider name
provider_meta "value" {
// {workdir} -> The only available placeholder currently (see below for more information)
seed_prefix = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
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):
```terraform
// Terraform providermeta example
terraform {
// "value" is the provider name
providermeta "value" {
// {workdir} -> The only available placeholder currently (see below for more information)
guidseed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
}
}
}
```
Optional
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.
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.
Placeholders:
"{workdir}" (Keyword) The actual workdir; equals to terraform's path.root. This placeholder is
recommended because this value won't be dragged along the plan and apply phase in comparison to
Expand All @@ -29,19 +29,19 @@ description: |-

Allows you to have a access to `result` during plan phase that states whether `value` marked as "(known after apply)" or not.
## Provider Metadata
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):
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)):
```terraform
// Terraform provider_meta example
terraform {
// "value" is the provider name
provider_meta "value" {
// {workdir} -> The only available placeholder currently (see below for more information)
seed_prefix = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
terraform {
// "value" is the provider name
provider_meta "value" {
// {workdir} -> The only available placeholder currently (see below for more information)
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
}
}
}
```
### Optional
- `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.
- `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.

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

### Required

- `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.
- `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!
- `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.
- `value` (Dynamic) The `value` (not nested attributes) is test against "(known after apply)"

### Optional
Expand Down
13 changes: 0 additions & 13 deletions examples/is_fully_known/provider_meta.tf

This file was deleted.

6 changes: 0 additions & 6 deletions examples/is_fully_known/shared.tf

This file was deleted.

21 changes: 21 additions & 0 deletions examples/is_fully_known/terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
terraform {
required_providers {
value = {
source = "github.com/pseudo-dynamic/value"
version = "0.1.0"
}
}

provider_meta "value" {
// Module-scoped seed addition.
// {workdir} -> a placeholder (see docs)
guid_seed_addition = "module(is-fully-known)"
}
}

provider "value" {
// Project-wide seed addition.
// Won't overwrite module-scoped seed addition,
// instead both serve are now considered as seed addition.
guid_seed_addition = "{workdir}"
}
12 changes: 7 additions & 5 deletions examples/is_fully_known/test_known.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!
// This example is complete but there are additional features implemented in terraform.tf!

resource "value_unknown_proposer" "known" {}

resource "value_is_fully_known" "known" {
value = "test"
unique_seed = "known"
proposed_unknown = value_unknown_proposer.default.value
guid_seed = "known"
proposed_unknown = value_unknown_proposer.known.value
}

output "is_known_value" {
value = {
is_fully_known = value_is_fully_known.known.result
fully_known = value_is_fully_known.known.result
}
}
}
14 changes: 10 additions & 4 deletions examples/is_fully_known/test_known_with_nested_unknown.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!
// This example is complete but there are additional features implemented in terraform.tf!

resource "value_unknown_proposer" "known_with_nested_unknown" {}

resource "value_promise" "known_with_nested_unknown" {
value = "test"
}

resource "value_is_fully_known" "known_with_nested_unknown" {
value = {
nested = value_promise.default.result
nested = value_promise.known_with_nested_unknown.result
}

unique_seed = "nested_known"
proposed_unknown = value_unknown_proposer.default.value
guid_seed = "nested_unknown"
proposed_unknown = value_unknown_proposer.known_with_nested_unknown.value
}

output "is_known_with_nested_unknown_value" {
Expand Down
16 changes: 11 additions & 5 deletions examples/is_fully_known/test_unknown.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!
// This example is complete but there are additional features implemented in terraform.tf!

resource "value_unknown_proposer" "unknown" {}

resource "value_promise" "unknown" {
value = "test"
}

resource "value_is_fully_known" "unknown" {
value = value_promise.default.result
unique_seed = "unknown"
proposed_unknown = value_unknown_proposer.default.value
value = value_promise.unknown.result
guid_seed = "unknown"
proposed_unknown = value_unknown_proposer.unknown.value
}

output "is_unknown_value" {
value = {
is_fully_known = value_is_fully_known.unknown.result
fully_known = value_is_fully_known.unknown.result
}
}
13 changes: 0 additions & 13 deletions examples/is_known/provider_meta.tf

This file was deleted.

6 changes: 0 additions & 6 deletions examples/is_known/shared.tf

This file was deleted.

21 changes: 21 additions & 0 deletions examples/is_known/terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
terraform {
required_providers {
value = {
source = "github.com/pseudo-dynamic/value"
version = "0.1.0"
}
}

provider_meta "value" {
// Module-scoped seed addition.
// {workdir} -> a placeholder (see docs)
guid_seed_addition = "module(is-known)"
}
}

provider "value" {
// Project-wide seed addition.
// Won't overwrite module-scoped seed addition,
// instead both serve are now considered as seed addition.
guid_seed_addition = "{workdir}"
}
24 changes: 13 additions & 11 deletions examples/is_known/test_known.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# // This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!
// This example is complete but there are additional features implemented in terraform.tf!

# resource "value_is_known" "known" {
# value = "test"
# unique_seed = "known"
# proposed_unknown = value_unknown_proposer.default.value
# }
resource "value_unknown_proposer" "known" {}

# output "is_known_value" {
# value = {
# known = value_is_known.known.result
# }
# }
resource "value_is_known" "known" {
value = "test"
guid_seed = "known"
proposed_unknown = value_unknown_proposer.known.value
}

output "is_known_value" {
value = {
known = value_is_known.known.result
}
}
14 changes: 10 additions & 4 deletions examples/is_known/test_known_with_nested_unknown.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!
// This example is complete but there are additional features implemented in terraform.tf!

resource "value_unknown_proposer" "known_with_nested_unknown" {}

resource "value_promise" "known_with_nested_unknown" {
value = "test"
}

resource "value_is_known" "known_with_nested_unknown" {
value = {
nested = value_promise.default.result
nested = value_promise.known_with_nested_unknown.result
}

unique_seed = "nested_known"
proposed_unknown = value_unknown_proposer.default.value
guid_seed = "nested_unknown"
proposed_unknown = value_unknown_proposer.known_with_nested_unknown.value
}

output "is_known_with_nested_unknown_value" {
Expand Down
32 changes: 19 additions & 13 deletions examples/is_known/test_unknown.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# // This example is incomplete. Please take a look at provider_meta.tf and shared.tf too!

# resource "value_is_known" "unknown" {
# value = value_promise.default.result
# unique_seed = "unknown"
# proposed_unknown = value_unknown_proposer.default.value
# }

# output "is_unknown_value" {
# value = {
# known = value_is_known.unknown.result
# }
# }
// This example is complete but there are additional features implemented in terraform.tf!

resource "value_unknown_proposer" "unknown" {}

resource "value_promise" "unknown" {
value = "test"
}

resource "value_is_known" "unknown" {
value = value_promise.unknown.result
guid_seed = "unknown"
proposed_unknown = value_unknown_proposer.unknown.value
}

output "is_unknown_value" {
value = {
known = value_is_known.unknown.result
}
}
Loading

0 comments on commit 63300d5

Please sign in to comment.