File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -375,9 +375,10 @@ func ResourceServer() *schema.Resource {
375375 },
376376 },
377377 "admin_password_encryption_ssh_key_id" : {
378- Type : schema .TypeString ,
379- Optional : true ,
380- Description : "The ID of the IAM SSH key used to encrypt the initial admin password on a Windows server" ,
378+ Type : schema .TypeString ,
379+ Optional : true ,
380+ ValidateDiagFunc : verify .IsUUIDOrEmpty (),
381+ Description : "The ID of the IAM SSH key used to encrypt the initial admin password on a Windows server" ,
381382 },
382383 "zone" : zonal .Schema (),
383384 "organization_id" : account .OrganizationIDSchema (),
Original file line number Diff line number Diff line change @@ -42,6 +42,34 @@ func IsUUID() schema.SchemaValidateDiagFunc {
4242 }
4343}
4444
45+ func IsUUIDOrEmpty () schema.SchemaValidateDiagFunc {
46+ return func (value any , path cty.Path ) diag.Diagnostics {
47+ uuid , isString := value .(string )
48+ if ! isString {
49+ return diag.Diagnostics {diag.Diagnostic {
50+ Severity : diag .Error ,
51+ Summary : "invalid UUID not a string" ,
52+ AttributePath : path ,
53+ }}
54+ }
55+
56+ if uuid == "" {
57+ return nil
58+ }
59+
60+ if ! validation .IsUUID (uuid ) {
61+ return diag.Diagnostics {diag.Diagnostic {
62+ Severity : diag .Error ,
63+ Summary : "invalid UUID: " + uuid ,
64+ AttributePath : path ,
65+ Detail : "format should be 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' (36) and contains valid hexadecimal characters" ,
66+ }}
67+ }
68+
69+ return nil
70+ }
71+ }
72+
4573func IsUUIDWithLocality () schema.SchemaValidateDiagFunc {
4674 return func (value any , path cty.Path ) diag.Diagnostics {
4775 uuid , isString := value .(string )
You can’t perform that action at this time.
0 commit comments