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 <krzysztof.wilczynski@linux.com>
This commit is contained in:
Krzysztof Wilczynski 2016-09-18 14:26:28 +01:00 committed by Radek Simko
parent 05402b8bd0
commit 056d53e1fe
1 changed files with 9 additions and 4 deletions

View File

@ -54,9 +54,13 @@ func resourceAwsGlacierVault() *schema.Resource {
}, },
"access_policy": &schema.Schema{ "access_policy": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
StateFunc: normalizeJson, ValidateFunc: validateJsonString,
StateFunc: func(v interface{}) string {
json, _ := normalizeJsonString(v)
return json
},
}, },
"notification": &schema.Schema{ "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" { if awserr, ok := err.(awserr.Error); ok && awserr.Code() == "ResourceNotFoundException" {
d.Set("access_policy", "") d.Set("access_policy", "")
} else if pol != nil { } else if pol != nil {
d.Set("access_policy", normalizeJson(*pol.Policy.Policy)) policy, _ := normalizeJsonString(*pol.Policy.Policy)
d.Set("access_policy", policy)
} else { } else {
return err return err
} }