@@ -233,6 +233,7 @@ def __init__(
233233 pull_image = True ,
234234 container_name = None ,
235235 use_ssl = False ,
236+ persistent = False ,
236237 ** kwargs
237238 ):
238239 self ._container = None
@@ -244,6 +245,7 @@ def __init__(
244245 self .dynamodb_error_probability = dynamodb_error_probability
245246 self .auto_remove = bool (auto_remove )
246247 self .pull_image = bool (pull_image )
248+ self .persistent = persistent
247249
248250 super (LocalstackSession , self ).__init__ (
249251 hostname = constants .LOCALHOST ,
@@ -289,6 +291,16 @@ def start(self, timeout=60):
289291 kinesis_error_probability = "%f" % self .kinesis_error_probability
290292 dynamodb_error_probability = "%f" % self .dynamodb_error_probability
291293 use_ssl = str (self .use_ssl ).lower ()
294+ environment = {
295+ "DEFAULT_REGION" : self .region_name ,
296+ "SERVICES" : services ,
297+ "KINESIS_ERROR_PROBABILITY" : kinesis_error_probability ,
298+ "DYNAMODB_ERROR_PROBABILITY" : dynamodb_error_probability ,
299+ "USE_SSL" : use_ssl ,
300+ }
301+
302+ if self .persistent :
303+ environment ['DATA_DIR' ] = '/tmp/localstack/data'
292304
293305 try :
294306 _container = self .docker_client .containers .get (self .container_name )
@@ -300,13 +312,7 @@ def start(self, timeout=60):
300312 name = self .container_name ,
301313 detach = True ,
302314 auto_remove = self .auto_remove ,
303- environment = {
304- "DEFAULT_REGION" : self .region_name ,
305- "SERVICES" : services ,
306- "KINESIS_ERROR_PROBABILITY" : kinesis_error_probability ,
307- "DYNAMODB_ERROR_PROBABILITY" : dynamodb_error_probability ,
308- "USE_SSL" : use_ssl ,
309- },
315+ environment = environment ,
310316 ports = {port : None for port in self .services .values ()},
311317 )
312318 logger .debug (
0 commit comments