From 056d53e1feac09191229673a8b26854cdcf96e4e Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Sun, 18 Sep 2016 14:26:28 +0100 Subject: [PATCH] Add JSON validation to the aws_glacier_vault resource. (#8899) 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_glacier_vault.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_glacier_vault.go b/builtin/providers/aws/resource_aws_glacier_vault.go index 99332f6e00..0ae09b61ba 100644 --- a/builtin/providers/aws/resource_aws_glacier_vault.go +++ b/builtin/providers/aws/resource_aws_glacier_vault.go @@ -54,9 +54,13 @@ func resourceAwsGlacierVault() *schema.Resource { }, "access_policy": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - StateFunc: normalizeJson, + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateJsonString, + StateFunc: func(v interface{}) string { + json, _ := normalizeJsonString(v) + return json + }, }, "notification": &schema.Schema{ @@ -159,7 +163,8 @@ func resourceAwsGlacierVaultRead(d *schema.ResourceData, meta interface{}) error if awserr, ok := err.(awserr.Error); ok && awserr.Code() == "ResourceNotFoundException" { d.Set("access_policy", "") } else if pol != nil { - d.Set("access_policy", normalizeJson(*pol.Policy.Policy)) + policy, _ := normalizeJsonString(*pol.Policy.Policy) + d.Set("access_policy", policy) } else { return err }