Handle JSON parsing error in the ReadFunc for the template body document.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
This commit is contained in:
parent
f1d3b21fd2
commit
749e6ba893
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -106,10 +107,11 @@ func dataSourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
template, _ := normalizeJsonString(*tOut.TemplateBody)
|
template, err := normalizeJsonString(*tOut.TemplateBody)
|
||||||
if err := d.Set("template_body", template); err != nil {
|
if err != nil {
|
||||||
return err
|
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