Merge pull request #8907 from kwilczynski/feature/json-validation-data_source_aws_cloudformation_stack
provider/aws: Update aws_cloudformation_stack data source with new helper function.
This commit is contained in:
commit
b2c7787380
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/cloudformation"
|
||||
"github.com/hashicorp/errwrap"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -20,7 +21,10 @@ func dataSourceAwsCloudFormationStack() *schema.Resource {
|
|||
"template_body": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
StateFunc: normalizeJson,
|
||||
StateFunc: func(v interface{}) string {
|
||||
json, _ := normalizeJsonString(v)
|
||||
return json
|
||||
},
|
||||
},
|
||||
"capabilities": {
|
||||
Type: schema.TypeSet,
|
||||
|
@ -103,7 +107,11 @@ func dataSourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface
|
|||
return err
|
||||
}
|
||||
|
||||
d.Set("template_body", normalizeJson(*tOut.TemplateBody))
|
||||
template, err := normalizeJsonString(*tOut.TemplateBody)
|
||||
if err != nil {
|
||||
return errwrap.Wrapf("template body contains an invalid JSON: {{err}}", err)
|
||||
}
|
||||
d.Set("template_body", template)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue