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.
func_name=TEST_LAMBDA_NAME_JAVA_WITH_LIB,
            zip_file=cls.test_java_jar_with_lib,
            runtime=LAMBDA_RUNTIME_JAVA8,
            handler='cloud.localstack.sample.LambdaHandlerWithLib'
        )
    @classmethod
    def tearDownClass(cls):
        
        testutil.delete_lambda_function(TEST_LAMBDA_NAME_JAVA)
        testutil.delete_lambda_function(TEST_LAMBDA_NAME_JAVA_STREAM)
        testutil.delete_lambda_function(TEST_LAMBDA_NAME_JAVA_SERIALIZABLE)
        testutil.delete_lambda_function(TEST_LAMBDA_NAME_JAVA_WITH_LIB)
    def test_java_runtime(self):
        self.assertIsNotNone(self.test_java_jar)
        result = self.lambda_client.invoke(
            FunctionName=TEST_LAMBDA_NAME_JAVA, Payload=b'{}')
        result_data = result['Payload'].read()
        self.assertEqual(result['StatusCode'], 200)
        self.assertIn('LinkedHashMap', to_str(result_data))
    def test_java_runtime_with_lib(self):
        self.assertIsNotNone(self.test_java_jar_with_lib)
        result = self.lambda_client.invoke(
            FunctionName=TEST_LAMBDA_NAME_JAVA_WITH_LIB, Payload=b'{"echo":"echo"}')
        result_data = result['Payload'].read()
        self.assertEqual(result['StatusCode'], 200)
        self.assertIn('echo', to_str(result_data))
    def test_sns_event(self):
        result = self.lambda_client.invoke(
            FunctionName=TEST_LAMBDA_NAME_JAVA, InvocationType='Event',
            Payload=b'{"Records": [{"Sns": {"Message": "{}"}}]}')