@@ -395,19 +395,23 @@ func resourceRestAPIUpdate(ctx context.Context, d *schema.ResourceData, meta int
395
395
// Remove every binary media types. Simpler to remove and add new ones,
396
396
// since there are no replacings.
397
397
for _ , v := range old {
398
- operations = append (operations , & apigateway.PatchOperation {
399
- Op : aws .String (apigateway .OpRemove ),
400
- Path : aws .String (fmt .Sprintf ("/%s/%s" , prefix , escapeJSONPointer (v .(string )))),
401
- })
398
+ if e , ok := v .(string ); ok {
399
+ operations = append (operations , & apigateway.PatchOperation {
400
+ Op : aws .String (apigateway .OpRemove ),
401
+ Path : aws .String (fmt .Sprintf ("/%s/%s" , prefix , escapeJSONPointer (e ))),
402
+ })
403
+ }
402
404
}
403
405
404
406
// Handle additions
405
407
if len (new ) > 0 {
406
408
for _ , v := range new {
407
- operations = append (operations , & apigateway.PatchOperation {
408
- Op : aws .String (apigateway .OpAdd ),
409
- Path : aws .String (fmt .Sprintf ("/%s/%s" , prefix , escapeJSONPointer (v .(string )))),
410
- })
409
+ if e , ok := v .(string ); ok {
410
+ operations = append (operations , & apigateway.PatchOperation {
411
+ Op : aws .String (apigateway .OpAdd ),
412
+ Path : aws .String (fmt .Sprintf ("/%s/%s" , prefix , escapeJSONPointer (e ))),
413
+ })
414
+ }
411
415
}
412
416
}
413
417
}
@@ -626,18 +630,22 @@ func resourceRestAPIWithBodyUpdateOperations(d *schema.ResourceData, output *api
626
630
}
627
631
628
632
if v , ok := d .GetOk ("binary_media_types" ); ok && len (v .([]interface {})) > 0 {
629
- for _ , elem := range aws .StringValueSlice (output .BinaryMediaTypes ) {
630
- operations = append (operations , & apigateway.PatchOperation {
631
- Op : aws .String (apigateway .OpRemove ),
632
- Path : aws .String ("/binaryMediaTypes/" + escapeJSONPointer (elem )),
633
- })
633
+ if len (output .BinaryMediaTypes ) > 0 {
634
+ for _ , elem := range aws .StringValueSlice (output .BinaryMediaTypes ) {
635
+ operations = append (operations , & apigateway.PatchOperation {
636
+ Op : aws .String (apigateway .OpRemove ),
637
+ Path : aws .String ("/binaryMediaTypes/" + escapeJSONPointer (elem )),
638
+ })
639
+ }
634
640
}
635
641
636
642
for _ , elem := range v .([]interface {}) {
637
- operations = append (operations , & apigateway.PatchOperation {
638
- Op : aws .String (apigateway .OpAdd ),
639
- Path : aws .String ("/binaryMediaTypes/" + escapeJSONPointer (elem .(string ))),
640
- })
643
+ if el , ok := elem .(string ); ok {
644
+ operations = append (operations , & apigateway.PatchOperation {
645
+ Op : aws .String (apigateway .OpAdd ),
646
+ Path : aws .String ("/binaryMediaTypes/" + escapeJSONPointer (el )),
647
+ })
648
+ }
641
649
}
642
650
}
643
651
0 commit comments