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/aws"
|
||||||
"github.com/aws/aws-sdk-go/service/cloudformation"
|
"github.com/aws/aws-sdk-go/service/cloudformation"
|
||||||
|
"github.com/hashicorp/errwrap"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,9 +19,12 @@ func dataSourceAwsCloudFormationStack() *schema.Resource {
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"template_body": {
|
"template_body": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
StateFunc: normalizeJson,
|
StateFunc: func(v interface{}) string {
|
||||||
|
json, _ := normalizeJsonString(v)
|
||||||
|
return json
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
|
@ -103,7 +107,11 @@ func dataSourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface
|
||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue