@@ -177,7 +177,28 @@ describe("LocalstackPlugin", () => {
177177expect ( request . called ) . to . be . true ;
178178let templateUrl = request . firstCall . args [ 2 ] . TemplateURL ;
179179// url should either start with 'http://localhost' or 'http://127.0.0.1
180- expect ( templateUrl ) . to . satisfy ( ( url ) => url . startsWith ( `${ config . host } ` ) || url . startsWith ( 'http://127.0.0.1' ) ) ;
180+ expect ( templateUrl ) . to . satisfy ( ( url ) => url === `${ config . host } :4566/path/to/template` || url === 'http://127.0.0.1:4566/path/to/template' ) ;
181+ } ) ;
182+
183+ it ( 'should overwrite the S3 hostname with the value from environment variable' , async ( ) => {
184+ // Set environment variable to overwrite the default host
185+ process . env . AWS_ENDPOINT_URL = 'http://localstack:4566' ;
186+
187+ const pathToTemplate = 'https://s3.amazonaws.com/path/to/template' ;
188+ const request = sinon . stub ( awsProvider , 'request' ) ;
189+ instance = new LocalstackPlugin ( serverless , defaultPluginState ) ;
190+ await simulateBeforeDeployHooks ( instance ) ;
191+
192+ await awsProvider . request ( 's3' , 'foo' , {
193+ TemplateURL :pathToTemplate
194+ } ) ;
195+
196+ // Remove the environment variable again to not affect other tests
197+ delete process . env . AWS_ENDPOINT_URL
198+
199+ expect ( request . called ) . to . be . true ;
200+ let templateUrl = request . firstCall . args [ 2 ] . TemplateURL ;
201+ expect ( templateUrl ) . to . equal ( 'http://localstack:4566/path/to/template' ) ;
181202} ) ;
182203
183204it ( 'should not send validateTemplate calls to localstack' , async ( ) => {