Add JSON validation to the aws_s3_bucket 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:
parent
e8a7b5d1c6
commit
a35695a804
|
@ -48,6 +48,7 @@ func resourceAwsS3Bucket() *schema.Resource {
|
|||
"policy": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validateJsonString,
|
||||
DiffSuppressFunc: suppressEquivalentAwsPolicyDiffs,
|
||||
},
|
||||
|
||||
|
@ -112,7 +113,11 @@ func resourceAwsS3Bucket() *schema.Resource {
|
|||
"routing_rules": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
StateFunc: normalizeJson,
|
||||
ValidateFunc: validateJsonString,
|
||||
StateFunc: func(v interface{}) string {
|
||||
json, _ := normalizeJsonString(v)
|
||||
return json
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -465,11 +470,14 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
|
|||
if err := d.Set("policy", ""); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err := d.Set("policy", normalizeJson(*v)); err != nil {
|
||||
} else {
|
||||
policy, _ := normalizeJsonString(*v)
|
||||
if err := d.Set("policy", policy); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read the CORS
|
||||
cors, err := s3conn.GetBucketCors(&s3.GetBucketCorsInput{
|
||||
|
|
Loading…
Reference in New Issue