Skip to content

Commit 1035793

Browse files
Fix intg test by only unsetting termination protection when needed (#8589)
1 parent 7317bb0 commit 1035793

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/cfn/manager/api.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,14 @@ func (c *StackCollection) DeleteStackBySpec(ctx context.Context, s *Stack) (*Sta
582582
fmt.Sprintf("%s:%s", api.ClusterNameTag, c.spec.Metadata.Name))
583583
}
584584

585-
updateTerminationProtectionInput := &cloudformation.UpdateTerminationProtectionInput{
586-
StackName: s.StackId,
587-
EnableTerminationProtection: aws.Bool(false),
588-
}
589-
if _, err := c.cloudformationAPI.UpdateTerminationProtection(ctx, updateTerminationProtectionInput); err != nil {
590-
return nil, fmt.Errorf("disabling termination protection on stack %q: %w", *s.StackName, err)
585+
if s.EnableTerminationProtection != nil && *s.EnableTerminationProtection {
586+
updateTerminationProtectionInput := &cloudformation.UpdateTerminationProtectionInput{
587+
StackName: s.StackId,
588+
EnableTerminationProtection: aws.Bool(false),
589+
}
590+
if _, err := c.cloudformationAPI.UpdateTerminationProtection(ctx, updateTerminationProtectionInput); err != nil {
591+
return nil, fmt.Errorf("disabling termination protection on stack %q: %w", *s.StackName, err)
592+
}
591593
}
592594

593595
input := &cloudformation.DeleteStackInput{

0 commit comments

Comments
 (0)