Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

echoprovider: Add a new test-only v6 provider that echoes ephemeral provider data #389

Merged
merged 21 commits into from
Nov 19, 2024

Conversation

austinvalle
Copy link
Member

@austinvalle austinvalle commented Nov 8, 2024

The changes in this PR can be seen in use over at: hashicorp/terraform-provider-corner#283

This PR contains an implementation of a v6 Terraform provider that can be used to test ephemeral resources. As ephemeral data is not stored in Terraform artifacts (plan or state), that means that the terraform-plugin-testing Go module cannot help provider developers test that data directly.

The echo provider utilizes the ephemeral nature of provider configurations as a "passthrough" for data to be echoed later by the single echo managed resource type:

ephemeral "examplecloud_thing" "one" {
  name = "John Doe"
}

provider "echo" {
  # Provide the ephemeral data we want to run test assertions against
  data = ephemeral.examplecloud_thing.one
}

# The ephemeral data will be echoed into state
resource "echo" "test_one" {}

output "name_out" {
  # Will output "John Doe"!
  value = echo.test_one.data.name
}	

A more detailed example, along with accompanying state checks, can be found in the PRs website documentation: https://github.com/hashicorp/terraform-plugin-testing/blob/av/ephemeral-values/website/docs/plugin/testing/acceptance-tests/ephemeral-resources.mdx#testing-ephemeral-data-with-echo-provider


Eventually, other methods of inspecting/consuming ephemeral data may be introduced that might warrant revisiting this provider, such as:

  • Terraform core implementing their own "debug" utility for practitioners inspecting ephemeral data
  • Write-only attributes in managed resources

But for now, ephemeral data => provider config => managed resource state is essentially the only reasonable option for CI testing. (outside of using the remote system, which is encouraged in the docs)

Notes

@austinvalle austinvalle added the enhancement New feature or request label Nov 8, 2024
@austinvalle austinvalle added this to the v1.11.0 milestone Nov 8, 2024
echoprovider/server.go Outdated Show resolved Hide resolved
@austinvalle austinvalle changed the base branch from av/skip-if-not-alpha to main November 15, 2024 19:48
@austinvalle austinvalle merged commit 33bf5cf into main Nov 19, 2024
38 checks passed
@austinvalle austinvalle deleted the av/ephemeral-values branch November 19, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants