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:
Paul Stack 2016-09-22 09:31:51 +01:00 committed by GitHub
commit b2c7787380
1 changed files with 12 additions and 4 deletions

View File

@ -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"
)
@ -18,9 +19,12 @@ func dataSourceAwsCloudFormationStack() *schema.Resource {
Required: true,
},
"template_body": {
Type: schema.TypeString,
Computed: true,
StateFunc: normalizeJson,
Type: schema.TypeString,
Computed: true,
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
}