From df8ca94093cf3523559ee4d2f66288ddd377a6a9 Mon Sep 17 00:00:00 2001 From: stack72 Date: Mon, 26 Sep 2016 13:52:33 +0100 Subject: [PATCH] provider/aws: aws_db_option_group flattenOptions failing due to missing values Fixes #8332 Not all option_group parameters have values. For example, when you enable the MariaDB option_group, some of the settings have empty values (see screenshot) This PR adds a safety net on reading those values back to the statefile ``` % make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSDBOptionGroup_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2016/09/26 13:55:21 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSDBOptionGroup_ -timeout 120m === RUN TestAccAWSDBOptionGroup_importBasic --- PASS: TestAccAWSDBOptionGroup_importBasic (20.12s) === RUN TestAccAWSDBOptionGroup_basic --- PASS: TestAccAWSDBOptionGroup_basic (18.45s) === RUN TestAccAWSDBOptionGroup_basicDestroyWithInstance --- PASS: TestAccAWSDBOptionGroup_basicDestroyWithInstance (597.90s) === RUN TestAccAWSDBOptionGroup_OptionSettings --- PASS: TestAccAWSDBOptionGroup_OptionSettings (33.27s) === RUN TestAccAWSDBOptionGroup_sqlServerOptionsUpdate --- PASS: TestAccAWSDBOptionGroup_sqlServerOptionsUpdate (33.39s) === RUN TestAccAWSDBOptionGroup_multipleOptions --- PASS: TestAccAWSDBOptionGroup_multipleOptions (19.87s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 723.037s ``` --- builtin/providers/aws/structure.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index 925abf8f4..c7c372219 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -624,10 +624,14 @@ func flattenOptions(list []*rds.Option) []map[string]interface{} { if i.OptionSettings != nil { settings := make([]map[string]interface{}, 0, len(i.OptionSettings)) for _, j := range i.OptionSettings { - settings = append(settings, map[string]interface{}{ - "name": *j.Name, - "value": *j.Value, - }) + setting := map[string]interface{}{ + "name": *j.Name, + } + if j.Value != nil { + setting["value"] = *j.Value + } + + settings = append(settings, setting) } r["option_settings"] = settings