@@ -19,6 +19,7 @@ function getRandomInt(max) {
19
19
* @return {Promise } which resolves into the function configuration
20
20
*/
21
21
function getFunction ( name ) {
22
+ console . log ( 'Function name: ' , name ) ;
22
23
return new Promise ( ( resolve , reject ) => {
23
24
lambda . getFunctionConfiguration ( {
24
25
FunctionName : name
@@ -36,6 +37,7 @@ function getFunction(name) {
36
37
*/
37
38
function getFunctionVersions ( name , marker ) {
38
39
// Grab functions
40
+ console . log ( 'Function versions: ' , name ) ;
39
41
return new Promise ( ( resolve , reject ) => {
40
42
lambda . listVersionsByFunction ( {
41
43
FunctionName : name ,
@@ -61,6 +63,7 @@ function getFunctionVersions(name, marker) {
61
63
* @return {Promise } which resolves into the newly published version
62
64
*/
63
65
function functionPublishVersion ( name , description , hash ) {
66
+ console . log ( 'Publishing function version: ' , name ) ;
64
67
return new Promise ( ( resolve , reject ) => {
65
68
lambda . publishVersion ( {
66
69
FunctionName : name ,
@@ -100,21 +103,24 @@ exports.handler = function(event, context) {
100
103
return response . send ( event , context , response . SUCCESS , { } ) ;
101
104
}
102
105
103
- // Grab the function first
104
- getFunction ( properties . FunctionName ) . then ( function ( fn ) {
105
- // Then grab all versions
106
- return getFunctionVersions ( fn . FunctionName ) . then ( ( versions ) => {
107
- // Try to find one that matches the function configuration
108
- versions = versions . filter ( ( version ) => {
109
- // Ignore the latest pseudo-version
110
- return version . Version !== '$LATEST' ;
111
- } ) ;
106
+ // Artificial delay to prevent deploys from hitting internal AWS API limits
107
+ delay ( getRandomInt ( 15000 ) ) . then ( ( ) => {
108
+ // Grab the function first
109
+ return getFunction ( properties . FunctionName ) . then ( function ( fn ) {
110
+ // Then grab all versions
111
+ return getFunctionVersions ( fn . FunctionName ) . then ( ( versions ) => {
112
+ // Try to find one that matches the function configuration
113
+ versions = versions . filter ( ( version ) => {
114
+ // Ignore the latest pseudo-version
115
+ return version . Version !== '$LATEST' ;
116
+ } ) ;
112
117
113
- const trimmedFn = _ . pick ( fn , 'LastModified' ) ;
114
- return {
115
- fn : fn ,
116
- version : _ . find ( versions , trimmedFn )
117
- } ;
118
+ const trimmedFn = _ . pick ( fn , 'LastModified' ) ;
119
+ return {
120
+ fn : fn ,
121
+ version : _ . find ( versions , trimmedFn )
122
+ } ;
123
+ } ) ;
118
124
} ) ;
119
125
} ) . then ( ( results ) => {
120
126
return delay ( getRandomInt ( 5000 ) ) . then ( function ( ) {
0 commit comments