From d71ff1e1223097d310bec5b117fb1c91c3f95718 Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Wed, 14 Sep 2016 18:00:38 +0100 Subject: [PATCH] Add JSON validation to the aws_elasticsearch_domain resource. This commit adds support for new helper function which is used to normalise and validate JSON string. Signed-off-by: Krzysztof Wilczynski --- builtin/providers/aws/resource_aws_elasticsearch_domain.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_elasticsearch_domain.go b/builtin/providers/aws/resource_aws_elasticsearch_domain.go index 81e5b10c5..45303f671 100644 --- a/builtin/providers/aws/resource_aws_elasticsearch_domain.go +++ b/builtin/providers/aws/resource_aws_elasticsearch_domain.go @@ -23,8 +23,9 @@ func resourceAwsElasticSearchDomain() *schema.Resource { Schema: map[string]*schema.Schema{ "access_policies": &schema.Schema{ Type: schema.TypeString, - DiffSuppressFunc: suppressEquivalentAwsPolicyDiffs, Optional: true, + ValidateFunc: validateJsonString, + DiffSuppressFunc: suppressEquivalentAwsPolicyDiffs, }, "advanced_options": &schema.Schema{ Type: schema.TypeMap, @@ -269,7 +270,8 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{} ds := out.DomainStatus if ds.AccessPolicies != nil && *ds.AccessPolicies != "" { - d.Set("access_policies", normalizeJson(*ds.AccessPolicies)) + policies, _ := normalizeJsonString(*ds.AccessPolicies) + d.Set("access_policies", policies) } err = d.Set("advanced_options", pointersMapToStringList(ds.AdvancedOptions)) if err != nil {