44 "context"
55 "os"
66
7+ "github.com/google/uuid"
78 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
89 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
910 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -27,10 +28,17 @@ func aiTaskResource() *schema.Resource {
2728
2829 Description : "Use this resource to define Coder tasks." ,
2930 CreateContext : func (c context.Context , resourceData * schema.ResourceData , i any ) diag.Diagnostics {
31+ var diags diag.Diagnostics
32+
3033 if idStr := os .Getenv ("CODER_TASK_ID" ); idStr != "" {
3134 resourceData .SetId (idStr )
3235 } else {
33- return diag .Errorf ("CODER_TASK_ID must be set" )
36+ resourceData .SetId (uuid .NewString ())
37+
38+ diags = append (diags , diag.Diagnostic {
39+ Severity : diag .Warning ,
40+ Summary : "`CODER_TASK_ID` should be set, this will be an error in the future" ,
41+ })
3442 }
3543
3644 if prompt := os .Getenv ("CODER_TASK_PROMPT" ); prompt != "" {
@@ -58,7 +66,7 @@ func aiTaskResource() *schema.Resource {
5866 return diag .Errorf ("'app_id' must be set" )
5967 }
6068
61- return nil
69+ return diags
6270 },
6371 ReadContext : schema .NoopContext ,
6472 DeleteContext : schema .NoopContext ,
0 commit comments