@@ -56,6 +56,15 @@ func resourceEnvironment() *schema.Resource {
5656 "toolkit_path" : {
5757 Type : schema .TypeString ,
5858 Optional : true ,
59+ DiffSuppressFunc : func (k , old , new string , d * schema.ResourceData ) bool {
60+ // Suppress diff when transitioning from any value to empty/null
61+ // This allows silent migration from top-level toolkit_path to hosts.toolkit_path
62+ if new == "" || new == "null" {
63+ return true
64+ }
65+ // Suppress diff if both old and new are empty/null
66+ return (old == "" || old == "null" ) && (new == "" || new == "null" )
67+ },
5968 },
6069 "username" : {
6170 Type : schema .TypeString ,
@@ -204,6 +213,17 @@ func resourceEnvironment() *schema.Resource {
204213 Type : schema .TypeBool ,
205214 Default : true ,
206215 Optional : true ,
216+ DiffSuppressFunc : func (k , old , new string , d * schema.ResourceData ) bool {
217+ // Don't suppress if user explicitly changed the value in their config
218+ rawConfig := d .GetRawConfig ()
219+ if rawConfig .IsKnown () && ! rawConfig .IsNull () {
220+ ignoreTagChangesAttr := rawConfig .GetAttr ("ignore_tag_changes" )
221+ if (ignoreTagChangesAttr .IsNull () || ! ignoreTagChangesAttr .IsKnown ()) && new == "true" && (old == "" || old == "null" || old == "<null>" ) {
222+ return true
223+ }
224+ }
225+ return false
226+ },
207227 },
208228 "tags" : {
209229 Type : schema .TypeList ,
@@ -562,6 +582,18 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta i
562582 // its an import or upgrade, set to default value
563583 d .Set ("os_type" , "UNIX" )
564584 }
585+
586+ // This handles import scenario where parameter is not in config
587+ rawConfig := d .GetRawConfig ()
588+ if rawConfig .IsKnown () && ! rawConfig .IsNull () {
589+ ignoreTagChangesAttr := rawConfig .GetAttr ("ignore_tag_changes" )
590+ if ignoreTagChangesAttr .IsNull () || ! ignoreTagChangesAttr .IsKnown () {
591+ // Parameter not in config (import scenario) - set default
592+ d .Set ("ignore_tag_changes" , true )
593+ }
594+ } else {
595+ d .Set ("ignore_tag_changes" , true )
596+ }
565597
566598 envRes , _ := apiRes .(* dctapi.Environment )
567599 //d.SetId(envRes.GetId())
0 commit comments