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 <krzysztof.wilczynski@linux.com>
This commit is contained in:
Krzysztof Wilczynski 2016-09-14 18:00:38 +01:00
parent e8a7b5d1c6
commit d71ff1e122
No known key found for this signature in database
GPG Key ID: B89F6447B63419A6
1 changed files with 4 additions and 2 deletions

View File

@ -23,8 +23,9 @@ func resourceAwsElasticSearchDomain() *schema.Resource {
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"access_policies": &schema.Schema{ "access_policies": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
DiffSuppressFunc: suppressEquivalentAwsPolicyDiffs,
Optional: true, Optional: true,
ValidateFunc: validateJsonString,
DiffSuppressFunc: suppressEquivalentAwsPolicyDiffs,
}, },
"advanced_options": &schema.Schema{ "advanced_options": &schema.Schema{
Type: schema.TypeMap, Type: schema.TypeMap,
@ -269,7 +270,8 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{}
ds := out.DomainStatus ds := out.DomainStatus
if ds.AccessPolicies != nil && *ds.AccessPolicies != "" { 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)) err = d.Set("advanced_options", pointersMapToStringList(ds.AdvancedOptions))
if err != nil { if err != nil {