provider/aws: fix Elastic Beanstalk settings diff (#7398)

Fixes an issue where terraform plan or apply will always have a diff.
The Elastic Beanstalk API returns data for the `resource` attribute for
some settings that are not documented. This limits the `resource`
attribute to settings in the `aws:autoscaling:scheduledaction`
namespace.
This commit is contained in:
David Harris 2016-06-28 15:03:57 -06:00 committed by Paul Stack
parent 5e52bbaa27
commit 7abbb0f57e
1 changed files with 5 additions and 3 deletions

View File

@ -462,7 +462,7 @@ func fetchAwsElasticBeanstalkEnvironmentSettings(d *schema.ResourceData, meta in
return nil, fmt.Errorf("Error reading environment settings: option setting with no name: %v", optionSetting) return nil, fmt.Errorf("Error reading environment settings: option setting with no name: %v", optionSetting)
} }
if optionSetting.ResourceName != nil { if *optionSetting.Namespace == "aws:autoscaling:scheduledaction" && optionSetting.ResourceName != nil {
m["resource"] = *optionSetting.ResourceName m["resource"] = *optionSetting.ResourceName
} }
@ -647,8 +647,10 @@ func extractOptionSettings(s *schema.Set) []*elasticbeanstalk.ConfigurationOptio
OptionName: aws.String(setting.(map[string]interface{})["name"].(string)), OptionName: aws.String(setting.(map[string]interface{})["name"].(string)),
Value: aws.String(setting.(map[string]interface{})["value"].(string)), Value: aws.String(setting.(map[string]interface{})["value"].(string)),
} }
if v, ok := setting.(map[string]interface{})["resource"].(string); ok && v != "" { if *optionSetting.Namespace == "aws:autoscaling:scheduledaction" {
optionSetting.ResourceName = aws.String(v) if v, ok := setting.(map[string]interface{})["resource"].(string); ok && v != "" {
optionSetting.ResourceName = aws.String(v)
}
} }
settings = append(settings, &optionSetting) settings = append(settings, &optionSetting)
} }