mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Ephemeral variables (#3108)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org> Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
committed by
Christian Mesh
parent
528b778363
commit
013097b631
6
internal/command/e2etest/testdata/ephemeral-errors/variables/in-data-source.tf.disabled
vendored
Normal file
6
internal/command/e2etest/testdata/ephemeral-errors/variables/in-data-source.tf.disabled
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// Running this configuration is expected to have an error since data sources are not allowed
|
||||
// to use ephemeral values at all.
|
||||
data "simple_resource" "test_data1" {
|
||||
provider = simple.s1
|
||||
value = var.in
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Running this configuration is expected to return an error since variables not configured as ephemeral
|
||||
// are not allowed to use ephemeral values.
|
||||
module "test" {
|
||||
source = "./non-ephemeral-mod"
|
||||
in = var.in
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Running this configuration is expected to have an error since output blocks not configured as ephemeral
|
||||
// are not allowed to use ephemeral values.
|
||||
output "out" {
|
||||
value = var.in
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Running this configuration is expected to have an error since `value` is not a write-only argument.
|
||||
// Regular resources arguments are not allowed to use ephemeral variables and values
|
||||
resource "simple_resource" "test_res" {
|
||||
provider = simple.s1
|
||||
value = var.in
|
||||
}
|
||||
28
internal/command/e2etest/testdata/ephemeral-errors/variables/main.tf
vendored
Normal file
28
internal/command/e2etest/testdata/ephemeral-errors/variables/main.tf
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// the provider-plugin tests uses the -plugin-cache flag so terraform pulls the
|
||||
// test binaries instead of reaching out to the registry.
|
||||
terraform {
|
||||
required_providers {
|
||||
simple = {
|
||||
source = "registry.opentofu.org/hashicorp/simple"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "simple" {
|
||||
alias = "s1"
|
||||
}
|
||||
|
||||
variable "in" {
|
||||
ephemeral = true
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "in2" {
|
||||
ephemeral = true
|
||||
type = string
|
||||
default = "in2 default value just to test the validations"
|
||||
validation {
|
||||
condition = var.in2 != "fail_on_this_value"
|
||||
error_message = "variable 'in2' value '${var.in2}' cannot be 'fail_on_this_value'"
|
||||
}
|
||||
}
|
||||
8
internal/command/e2etest/testdata/ephemeral-errors/variables/non-ephemeral-mod/main.tf
vendored
Normal file
8
internal/command/e2etest/testdata/ephemeral-errors/variables/non-ephemeral-mod/main.tf
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// Module that is used strictly to test passing in and out ephemeral variables.
|
||||
variable "in" {
|
||||
type = string
|
||||
}
|
||||
|
||||
output "out" {
|
||||
value = var.in
|
||||
}
|
||||
Reference in New Issue
Block a user