@@ -169,6 +169,10 @@ func resourceBigipAs3Create(d *schema.ResourceData, meta interface{}) error {
169
169
tenantList , _ , applicationList := client .GetTenantList (as3Json )
170
170
tenantCount := strings .Split (tenantList , "," )
171
171
if tenantFilter != "" {
172
+ log .Printf ("[DEBUG] tenantFilter:%+v" , tenantFilter )
173
+ if ! contains (tenantCount , tenantFilter ) {
174
+ return fmt .Errorf ("tenant_filter: (%s) not exist in as3_json provided " , tenantFilter )
175
+ }
172
176
tenantList = tenantFilter
173
177
}
174
178
_ = d .Set ("tenant_list" , tenantList )
@@ -253,7 +257,11 @@ func resourceBigipAs3Exists(d *schema.ResourceData, meta interface{}) (bool, err
253
257
applicationList := d .Get ("application_list" ).(string )
254
258
tenantFilter := d .Get ("tenant_filter" ).(string )
255
259
if tenantFilter != "" {
256
- name = tenantFilter
260
+ if ! contains (strings .Split (name , "," ), tenantFilter ) {
261
+ log .Printf ("[WARNING]tenant_filter: (%s) not exist in as3_json provided " , tenantFilter )
262
+ } else {
263
+ name = tenantFilter
264
+ }
257
265
}
258
266
as3Resp , err := client .GetAs3 (name , applicationList )
259
267
if err != nil {
@@ -299,7 +307,11 @@ func resourceBigipAs3Update(d *schema.ResourceData, meta interface{}) error {
299
307
}
300
308
}
301
309
} else {
302
- tenantList = tenantFilter
310
+ if ! contains (strings .Split (tenantList , "," ), tenantFilter ) {
311
+ log .Printf ("[WARNING]tenant_filter: (%s) not exist in as3_json provided " , tenantFilter )
312
+ } else {
313
+ tenantList = tenantFilter
314
+ }
303
315
}
304
316
strTrimSpace , err := client .AddTeemAgent (as3Json )
305
317
if err != nil {
@@ -343,3 +355,12 @@ func resourceBigipAs3Delete(d *schema.ResourceData, meta interface{}) error {
343
355
d .SetId ("" )
344
356
return nil
345
357
}
358
+
359
+ func contains (s []string , str string ) bool {
360
+ for _ , v := range s {
361
+ if v == str {
362
+ return true
363
+ }
364
+ }
365
+ return false
366
+ }
0 commit comments