File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ func ResourceServer() *schema.Resource {
6868
6969 return ok && newValue == offerName
7070 },
71+ ValidateDiagFunc : verify .IsUUIDOrNameOffer (),
7172 },
7273 "offer_id" : {
7374 Type : schema .TypeString ,
Original file line number Diff line number Diff line change 11package verify
22
33import (
4+ "fmt"
45 "github.com/hashicorp/go-cty/cty"
56 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
67 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -66,3 +67,29 @@ func IsUUIDWithLocality() schema.SchemaValidateDiagFunc {
6667 return IsUUID ()(subUUID , path )
6768 }
6869}
70+
71+ func IsUUIDOrNameOffer () schema.SchemaValidateDiagFunc {
72+ return func (value interface {}, path cty.Path ) diag.Diagnostics {
73+ uuid , _ := value .(string )
74+ if ! validation .IsUUID (uuid ) {
75+ return diag.Diagnostics {diag.Diagnostic {
76+ Severity : diag .Warning ,
77+ Summary : "Using a datasource for better consistency and reliability is recommended instead of directly using offer names." ,
78+ AttributePath : path ,
79+ Detail : fmt .Sprintf (
80+ `The offer name should be retrieved using a datasource to ensure reliable and consistent configuration.
81+
82+ Example:
83+ data "scaleway_baremetal_offer" "my_offer_monthly" {
84+ zone = "fr-par-2"
85+ name = "EM-B112X-SSD"
86+ subscription_period = "monthly"
87+ }
88+
89+ Then, you can reference the datasource's attributes in your resources.` ,
90+ ),
91+ }}
92+ }
93+ return nil
94+ }
95+ }
You can’t perform that action at this time.
0 commit comments