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:
parent
05402b8bd0
commit
056d53e1fe
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue