When you create a Lambda permission you send the __statement id__ as mandatory parameter.

https://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html#API_AddPermission_RequestSyntax

However this id is generated by a random value. 

https://github.com/localstack/localstack/blob/b3917bf248b77ced8ef80a3d5c0561960066db5d/localstack/services/awslambda/lambda_api.py#L927

Due to this problem, the tools like Terraform or Ansible fail when it has to be retrieved to check the existence of this element.

If you agree I could make a PR with the fix and its test.
zip_file=zip_file,
            runtime=LAMBDA_RUNTIME_PYTHON27,
            envvars={'Hello': 'World'}
        )
        self.assertEqual(len(executor.get_all_container_names()), 0)
        self.assertDictEqual(executor.function_invoke_times, {})
        
        durations = []
        num_iterations = 3
        for i in range(0, num_iterations + 1):
            prev_invoke_time = None
            if i > 0:
                prev_invoke_time = executor.function_invoke_times[func_arn]
            start_time = time.time()
            self.lambda_client.invoke(FunctionName=func_name, Payload=b'{}')
            duration = time.time() - start_time
            self.assertEqual(len(executor.get_all_container_names()), 1)
            
            if i > 0:
                self.assertGreater(executor.function_invoke_times[func_arn], prev_invoke_time)
            else:
                self.assertGreater(executor.function_invoke_times[func_arn], 0)
            durations.append(duration)
        
        for i in range(1, num_iterations + 1):
            self.assertLess(durations[i], durations[0])
        status = executor.get_docker_container_status(func_arn)
        self.assertEqual(status, 1)
        container_network = executor.get_docker_container_network(func_arn)
        self.assertEqual(container_network, 'default')