Skip to content

Commit

Permalink
add nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcervante committed Apr 22, 2024
1 parent 35bc041 commit 29c879c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/terraform/node_resource_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,15 @@ func (n *nodeExpandPlannableResource) ModifyCreateBeforeDestroy(v bool) error {
func (n *nodeExpandPlannableResource) DynamicExpand(ctx EvalContext) (*Graph, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics

// First, make sure the count and the foreach don't refer to the same resource
diags = diags.Append(validateSelfRefInExpr(n.Addr.Resource, n.Config.Count))
diags = diags.Append(validateSelfRefInExpr(n.Addr.Resource, n.Config.ForEach))
if diags.HasErrors() {
return nil, diags
// First, make sure the count and the foreach don't refer to the same
// resource. The config maybe nil if we are generating configuration, or
// deleting a resource.
if n.Config != nil {
diags = diags.Append(validateSelfRefInExpr(n.Addr.Resource, n.Config.Count))
diags = diags.Append(validateSelfRefInExpr(n.Addr.Resource, n.Config.ForEach))
if diags.HasErrors() {
return nil, diags
}
}

// Expand the current module.
Expand Down

0 comments on commit 29c879c

Please sign in to comment.