@@ -97,7 +97,6 @@ func resourceAwsElasticBeanstalkEnvironment() *schema.Resource {
97
97
"setting" : & schema.Schema {
98
98
Type : schema .TypeSet ,
99
99
Optional : true ,
100
- Computed : true ,
101
100
Elem : resourceAwsElasticBeanstalkOptionSetting (),
102
101
Set : optionSettingValueHash ,
103
102
},
@@ -329,7 +328,39 @@ func resourceAwsElasticBeanstalkEnvironmentUpdate(d *schema.ResourceData, meta i
329
328
os := o .(* schema.Set )
330
329
ns := n .(* schema.Set )
331
330
332
- updateOpts .OptionSettings = extractOptionSettings (ns .Difference (os ))
331
+ rm := extractOptionSettings (os .Difference (ns ))
332
+ add := extractOptionSettings (ns .Difference (os ))
333
+
334
+ // Additions and removals of options are done in a single API call, so we
335
+ // can't do our normal "remove these" and then later "add these", re-adding
336
+ // any updated settings.
337
+ // Because of this, we need to remove any settings in the "removable"
338
+ // settings that are also found in the "add" settings, otherwise they
339
+ // conflict. Here we loop through all the initial removables from the set
340
+ // difference, and we build up a slice of settings not found in the "add"
341
+ // set
342
+ var remove []* elasticbeanstalk.ConfigurationOptionSetting
343
+ if len (add ) > 0 {
344
+ for _ , r := range rm {
345
+ for _ , a := range add {
346
+ if * r .Namespace == * a .Namespace && * r .OptionName == * a .OptionName {
347
+ continue
348
+ }
349
+ remove = append (remove , r )
350
+ }
351
+ }
352
+ } else {
353
+ remove = rm
354
+ }
355
+
356
+ for _ , elem := range remove {
357
+ updateOpts .OptionsToRemove = append (updateOpts .OptionsToRemove , & elasticbeanstalk.OptionSpecification {
358
+ Namespace : elem .Namespace ,
359
+ OptionName : elem .OptionName ,
360
+ })
361
+ }
362
+
363
+ updateOpts .OptionSettings = add
333
364
}
334
365
335
366
if d .HasChange ("template_name" ) {
0 commit comments