@@ -36,41 +36,50 @@ module.exports = {
3636
3737 } ,
3838
39- /**
40- * Load all deployed alias stack templates excluding the current alias.
41- */
42- aliasStackLoadAliasTemplates ( ) {
39+ aliasStackGetAliasStackNames ( ) {
4340
4441 const params = {
4542 ExportName : `${ this . _provider . naming . getStackName ( ) } -ServerlessAliasReference`
4643 } ;
4744
48- return this . _provider . request ( 'CloudFormation' , // eslint-disable-line lodash/prefer-lodash-method
45+ return this . _provider . request ( 'CloudFormation' ,
4946 'listImports' ,
5047 params ,
5148 this . _options . stage ,
5249 this . _options . region )
53- . then ( cfData => BbPromise . resolve ( cfData . Imports ) )
54- . filter ( stack => stack !== `${ this . _provider . naming . getStackName ( ) } -${ this . _alias } ` )
55- . mapSeries ( stack => {
50+ . then ( cfData => BbPromise . resolve ( cfData . Imports ) ) ;
5651
57- const importParams = {
58- StackName : stack ,
59- TemplateStage : 'Original' // We need the original references to look up the version resources.
60- } ;
52+ } ,
6153
62- return this . _provider . request ( 'CloudFormation' ,
63- 'getTemplate' ,
64- importParams ,
65- this . _options . stage ,
66- this . _options . region )
67- . then ( cfData => {
68- return BbPromise . resolve ( JSON . parse ( cfData . TemplateBody ) ) ;
69- } )
70- . catch ( err => {
71- return BbPromise . reject ( new Error ( `Unable to retrieve current stack information: ${ err . statusCode } ` ) ) ;
72- } ) ;
54+ aliasStackLoadTemplate ( stackName , processed ) {
55+
56+ const params = {
57+ StackName : stackName ,
58+ TemplateStage : processed ? 'Processed' : 'Original'
59+ } ;
60+
61+ return this . _provider . request ( 'CloudFormation' ,
62+ 'getTemplate' ,
63+ params ,
64+ this . _options . stage ,
65+ this . _options . region )
66+ . then ( cfData => {
67+ return BbPromise . resolve ( JSON . parse ( cfData . TemplateBody ) ) ;
7368 } )
69+ . catch ( err => {
70+ return BbPromise . reject ( new Error ( `Unable to retrieve template for ${ stackName } : ${ err . statusCode } ` ) ) ;
71+ } ) ;
72+
73+ } ,
74+
75+ /**
76+ * Load all deployed alias stack templates excluding the current alias.
77+ */
78+ aliasStackLoadAliasTemplates ( ) {
79+
80+ return this . aliasStackGetAliasStackNames ( ) // eslint-disable-line lodash/prefer-lodash-method
81+ . filter ( stack => stack !== `${ this . _provider . naming . getStackName ( ) } -${ this . _alias } ` )
82+ . mapSeries ( stack => this . aliasStackLoadTemplate ( stack ) )
7483 . catch ( err => {
7584 if ( err . statusCode === 400 ) {
7685 // The export is not yet there. Can happen on the very first alias stack deployment.
0 commit comments