File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 66import { AwsCredentials } from './awsCredentials.js' ;
77import { AwsConfiguration } from './types/awsConfiguration.js' ;
88import { Logger } from './logger.js' ;
9+ import * as yaml from 'yaml' ;
910
1011let cloudFormationClient : CloudFormationClient ;
1112
@@ -30,7 +31,17 @@ async function getCloudFormationStackTemplate(
3031 throw new Error ( `No template found for stack ${ stackName } ` ) ;
3132 }
3233
33- const cfTemplate = JSON . parse ( response . TemplateBody ) ;
34+ let cfTemplate : any ;
35+ try {
36+ cfTemplate = JSON . parse ( response . TemplateBody ) ;
37+ } catch ( parseError : any ) {
38+ if ( parseError . message . includes ( 'is not valid JSON' ) ) {
39+ // If the template is not JSON, try parsing it as YAML
40+ cfTemplate = yaml . parse ( response . TemplateBody ) ;
41+ } else {
42+ throw parseError ;
43+ }
44+ }
3445 return cfTemplate ;
3546 } catch ( error : any ) {
3647 if ( error . name === 'ValidationError' ) {
You can’t perform that action at this time.
0 commit comments