@@ -181,9 +181,35 @@ func parameterDataSource() *schema.Resource {
181
181
}
182
182
183
183
if parameter .Default != "" {
184
- _ , defaultIsValid := values [parameter .Default ]
185
- if ! defaultIsValid {
186
- return diag .Errorf ("default value %q must be defined as one of options" , parameter .Default )
184
+ if parameter .Type == "list(string)" && optionType == "string" {
185
+ // If the type is list(string) and optionType is string, we have
186
+ // to ensure all elements of the default exist as options.
187
+ var defaultValues []string
188
+ err = json .Unmarshal ([]byte (parameter .Default ), & defaultValues )
189
+ if err != nil {
190
+ return diag .Errorf ("default value %q is not a list of strings" , parameter .Default )
191
+ }
192
+
193
+ var missing []string
194
+ for _ , defaultValue := range defaultValues {
195
+ _ , defaultIsValid := values [defaultValue ]
196
+ if ! defaultIsValid {
197
+ missing = append (missing , defaultValue )
198
+ }
199
+ }
200
+
201
+ if len (missing ) > 0 {
202
+ return diag .Errorf (
203
+ "default value %q is not a valid option, values %q are missing from the option" ,
204
+ parameter .Default , strings .Join (missing , ", " ),
205
+ )
206
+ }
207
+
208
+ } else {
209
+ _ , defaultIsValid := values [parameter .Default ]
210
+ if ! defaultIsValid {
211
+ return diag .Errorf ("%q default value %q must be defined as one of options" , parameter .FormType , parameter .Default )
212
+ }
187
213
}
188
214
}
189
215
}
0 commit comments