@@ -29,10 +29,14 @@ class LocalstackPlugin {
2929 this . hooks = { } ;
3030 // Define a before-hook for all event types
3131 for ( let event in this . serverless . pluginManager . hooks ) {
32- if ( ( event . startsWith ( 'before:' ) || event . startsWith ( 'aws:common:validate' ) ) && ! this . hooks [ event ] ) {
32+ const doAdd = event . startsWith ( 'before:' ) || event . startsWith ( 'aws:common:validate' ) ;
33+ if ( doAdd && ! this . hooks [ event ] ) {
3334 this . hooks [ event ] = this . beforeEventHook . bind ( this , event ) ;
3435 }
3536 }
37+ // Define a hook for aws:info to fix output data
38+ this . hooks [ 'aws:info:gatherData' ] = this . fixOutputEndpoints . bind ( this ) ;
39+
3640
3741 this . awsServices = {
3842 'apigateway' : 4567 ,
@@ -55,7 +59,8 @@ class LocalstackPlugin {
5559 'rds' : 4594 ,
5660 'elasticache' : 4598 ,
5761 'secretsmanager' : 4584 ,
58- 'logs' : 4584
62+ 'logs' : 4586 ,
63+ 'cloudwatchlogs' : 4586
5964 } ;
6065
6166 // Intercept Provider requests
@@ -113,7 +118,6 @@ class LocalstackPlugin {
113118 this . getStageVariable ( ) ;
114119 return this . startLocalStack ( ) . then (
115120 ( ) => {
116- this . reconfigureAWS ( ) ;
117121 this . patchServerlessSecrets ( ) ;
118122 this . patchS3BucketLocationResponse ( ) ;
119123 }
@@ -192,6 +196,16 @@ class LocalstackPlugin {
192196 this . debug ( 'config.stage: ' + this . config . stage ) ;
193197 }
194198
199+ fixOutputEndpoints ( ) {
200+ const plugin = this . findPlugin ( 'AwsInfo' ) ;
201+ const endpoints = plugin . gatheredData . info . endpoints || [ ] ;
202+ endpoints . forEach ( ( entry , idx ) => {
203+ const regex = / .* : \/ \/ ( [ ^ \. ] + ) \. e x e c u t e - a p i [ ^ \/ ] + \/ ( [ ^ \/ ] + ) ( \/ .* ) ? / g;
204+ const replace = 'http://localhost:4567/restapis/$1/$2/_user_request_$3' ;
205+ endpoints [ idx ] = entry . replace ( regex , replace ) ;
206+ } ) ;
207+ }
208+
195209 /**
196210 * Start the LocalStack container in Docker, if it is not running yet.
197211 */
@@ -260,6 +274,7 @@ class LocalstackPlugin {
260274 /**
261275 * Create custom Serverless deployment bucket, if one is configured.
262276 */
277+ // TODO deprecated - should be removed
263278 createDeploymentBucket ( ) {
264279 const bucketName = this . serverless . service . provider . deploymentBucket ;
265280 if ( ! bucketName ) {
@@ -360,7 +375,7 @@ class LocalstackPlugin {
360375 this . awsProvider . sdk . config . update ( configChanges ) ;
361376
362377 // make sure the deployment bucket exists in the local environment
363- return this . createDeploymentBucket ( ) ;
378+ // return this.createDeploymentBucket();
364379 }
365380 else {
366381 this . endpoints = { }
0 commit comments