File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,13 +121,16 @@ function isNodeRuntime(runtime) {
121121
122122function getAllNodeFunctions ( ) {
123123 const functions = this . serverless . service . getAllFunctions ( ) ;
124+ const ecrImages = Object . keys ( this . serverless . service . provider ?. ecr ?. images || [ ] ) ;
124125
125126 return _ . filter ( functions , funcName => {
126127 const func = this . serverless . service . getFunction ( funcName ) ;
128+ const imageName = _ . get ( func , 'image.name' ) ;
129+ const isEcrImage = imageName && ecrImages . includes ( imageName ) ;
127130
128131 // if `uri` or `name` is provided or simple remote image path, it means the
129132 // image isn't built by Serverless so we shouldn't take care of it
130- if ( ( func . image && ( func . image . uri || func . image . name ) ) || ( func . image && typeof func . image === 'string' ) ) {
133+ if ( func . image ?. uri || ( func . image && typeof func . image === 'string' ) || ( func . image && imageName && ! isEcrImage ) ) {
131134 return false ;
132135 }
133136
Original file line number Diff line number Diff line change @@ -182,6 +182,33 @@ describe('Utils', () => {
182182
183183 expect ( Utils . getAllNodeFunctions . call ( { serverless : mockServerless } ) ) . toEqual ( [ 'foo' ] ) ;
184184 } ) ;
185+
186+ it ( 'should not ignore handlers with image.name property if defined as ecr image' , ( ) => {
187+ const mockServerless = {
188+ service : {
189+ getAllFunctions : jest . fn ( ( ) => [ 'foo' , 'bar' ] ) ,
190+ getFunction : jest . fn ( name => {
191+ if ( name === 'foo' ) {
192+ return { runtime : 'nodejs20.x' } ;
193+ }
194+ if ( name === 'bar' ) {
195+ return { runtime : 'nodejs22.x' , image : { name : 'fake-image-name' } } ;
196+ }
197+ } ) ,
198+ provider : {
199+ ecr : {
200+ images : {
201+ 'fake-image-name' : {
202+ path : './'
203+ }
204+ }
205+ }
206+ }
207+ }
208+ } ;
209+
210+ expect ( Utils . getAllNodeFunctions . call ( { serverless : mockServerless } ) ) . toEqual ( [ 'foo' , 'bar' ] ) ;
211+ } ) ;
185212 } ) ;
186213
187214 describe ( 'isProviderGoogle' , ( ) => {
You can’t perform that action at this time.
0 commit comments