Skip to content

Commit e4d4e8a

Browse files
authored
direct: do not resolve '$artifacts' in destroy (#3364)
## Why No need for this, seems to be TF-specific workaround. ## Tests Existing tests.
1 parent c30fa86 commit e4d4e8a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

cmd/bundle/destroy.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,19 @@ Typical use cases:
8282
return root.ErrAlreadyPrinted
8383
}
8484

85-
bundle.ApplySeqContext(ctx, b,
86-
// We need to resolve artifact variable (how we do it in build phase)
87-
// because some of the to-be-destroyed resource might use this variable.
88-
// Not resolving might lead to terraform "Reference to undeclared resource" error
89-
mutator.ResolveVariableReferencesWithoutResources("artifacts"),
90-
mutator.ResolveVariableReferencesOnlyResources("artifacts"),
91-
)
92-
93-
if logdiag.HasError(ctx) {
94-
return root.ErrAlreadyPrinted
85+
// not applicable to direct deployment, we don't need resource configuration there
86+
if !b.DirectDeployment {
87+
bundle.ApplySeqContext(ctx, b,
88+
// We need to resolve artifact variable (how we do it in build phase)
89+
// because some of the to-be-destroyed resource might use this variable.
90+
// Not resolving might lead to terraform "Reference to undeclared resource" error
91+
mutator.ResolveVariableReferencesWithoutResources("artifacts"),
92+
mutator.ResolveVariableReferencesOnlyResources("artifacts"),
93+
)
94+
95+
if logdiag.HasError(ctx) {
96+
return root.ErrAlreadyPrinted
97+
}
9598
}
9699

97100
phases.Destroy(ctx, b)

0 commit comments

Comments
 (0)