-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
stacks: allow unknown variables during apply operations #36311
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1463,7 +1463,11 @@ After applying this plan, Terraform will no longer manage these objects. You wil | |
ComponentInstanceAddr: mustAbsComponentInstance("component.main"), | ||
Dependencies: collections.NewSet(mustAbsComponent("component.self")), | ||
OutputValues: make(map[addrs.OutputValue]cty.Value), | ||
InputVariables: make(map[addrs.InputVariable]cty.Value), | ||
InputVariables: map[addrs.InputVariable]cty.Value{ | ||
mustInputVariable("input"): cty.UnknownVal(cty.Map(cty.Object(map[string]cty.Type{ | ||
"output": cty.String, | ||
}))), | ||
}, | ||
}, | ||
&stackstate.AppliedChangeInputVariable{ | ||
Addr: mustStackInputVariable("inputs"), | ||
|
@@ -2358,7 +2362,10 @@ func TestApplyWithFailedComponent(t *testing.T) { | |
ComponentInstanceAddr: mustAbsComponentInstance("component.self"), | ||
Dependencies: collections.NewSet(mustAbsComponent("component.parent")), | ||
OutputValues: make(map[addrs.OutputValue]cty.Value), | ||
InputVariables: make(map[addrs.InputVariable]cty.Value), | ||
InputVariables: map[addrs.InputVariable]cty.Value{ | ||
mustInputVariable("id"): cty.NullVal(cty.String), | ||
mustInputVariable("input"): cty.UnknownVal(cty.String), | ||
}, | ||
}, | ||
} | ||
|
||
|
@@ -3110,16 +3117,14 @@ func TestApplyWithChangedInputValues(t *testing.T) { | |
|
||
go Apply(ctx, &applyReq, &applyResp) | ||
applyChanges, applyDiags := collectApplyOutput(applyChangesCh, diagsCh) | ||
if len(applyDiags) != 1 { | ||
t.Fatalf("expected exactly two diagnostics, got %s", applyDiags.ErrWithWarnings()) | ||
} | ||
|
||
sort.SliceStable(applyDiags, diagnosticSortFunc(applyDiags)) | ||
expectDiagnosticsForTest(t, applyDiags, | ||
expectDiagnostic( | ||
tfdiags.Error, | ||
"Inconsistent value for input variable during apply", | ||
"The value for non-ephemeral input variable \"input\" was set to a different value during apply than was set during plan. Only ephemeral input variables can change between the plan and apply phases."), | ||
expectDiagnostic(tfdiags.Error, "Invalid inputs for component", "Invalid input variable definition object: attribute \"input\": string required."), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the extra diagnostic discussed in the description. This is the diagnostic that now prevents the bad component from actually applying. |
||
) | ||
|
||
wantChanges := []stackstate.AppliedChange{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
internal/stacks/stackruntime/testdata/mainbundle/test/removed-offline/child/child.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
terraform { | ||
required_providers { | ||
testing = { | ||
source = "hashicorp/testing" | ||
version = "0.1.0" | ||
} | ||
} | ||
} | ||
|
||
variable "value" { | ||
type = string | ||
} | ||
|
||
resource "testing_resource" "resource" { | ||
value = var.value | ||
} |
14 changes: 14 additions & 0 deletions
14
internal/stacks/stackruntime/testdata/mainbundle/test/removed-offline/parent/parent.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
required_providers { | ||
testing = { | ||
source = "hashicorp/testing" | ||
version = "0.1.0" | ||
} | ||
} | ||
} | ||
|
||
resource "testing_resource" "resource" {} | ||
|
||
output "value" { | ||
value = testing_resource.resource.id | ||
} |
28 changes: 28 additions & 0 deletions
28
.../stacks/stackruntime/testdata/mainbundle/test/removed-offline/removed-offline.tfstack.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
required_providers { | ||
testing = { | ||
source = "hashicorp/testing" | ||
version = "0.1.0" | ||
} | ||
} | ||
|
||
provider "testing" "default" {} | ||
|
||
component "parent" { | ||
source = "./parent" | ||
|
||
providers = { | ||
testing = provider.testing.default | ||
} | ||
} | ||
|
||
component "child" { | ||
source = "./child" | ||
|
||
providers = { | ||
testing = provider.testing.default | ||
} | ||
|
||
inputs = { | ||
value = component.parent.value | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was redundant, we also check the diagnostics on line 3121, so doing it twice was pointless.