Skip to content

Commit

Permalink
Make script field immutable for instance resource
Browse files Browse the repository at this point in the history
  • Loading branch information
uzaxirr committed Sep 3, 2024
1 parent 658b854 commit fe925f9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions civo/instances/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"errors"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"log"
"strings"
Expand Down Expand Up @@ -189,6 +190,7 @@ func ResourceInstance() *schema.Resource {
Update: schema.DefaultTimeout(30 * time.Minute),
Delete: schema.DefaultTimeout(30 * time.Minute),
},
CustomizeDiff: customizeDiffInstance,
}
}

Expand Down Expand Up @@ -610,3 +612,10 @@ func resourceInstanceDelete(ctx context.Context, d *schema.ResourceData, m inter

return nil
}

func customizeDiffInstance(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
if d.Id() != "" && d.HasChange("script") {
return fmt.Errorf("the 'script' field is immutable")
}
return nil
}

0 comments on commit fe925f9

Please sign in to comment.