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.
expected = ['.*Custom Runtime Lambda handler executing.']
        self.check_lambda_logs(
            TEST_LAMBDA_NAME_CUSTOM_RUNTIME, expected_lines=expected)
        
        testutil.delete_lambda_function(TEST_LAMBDA_NAME_CUSTOM_RUNTIME)
class TestDotNetCoreRuntimes(LambdaTestBase):
    @classmethod
    def setUpClass(cls):
        cls.lambda_client = aws_stack.connect_to_service('lambda')
        
        zip_file = TEST_LAMBDA_DOTNETCORE2
        cls.zip_file_content = None
        with open(zip_file, 'rb') as file_obj:
            cls.zip_file_content = file_obj.read()
    def test_dotnet_lambda_running_in_docker(self):
        if not use_docker():
            return
        testutil.create_lambda_function(
            func_name=TEST_LAMBDA_NAME_DOTNETCORE2,
            zip_file=self.zip_file_content,
            handler='DotNetCore2::DotNetCore2.Lambda.Function::SimpleFunctionHandler',
            runtime=LAMBDA_RUNTIME_DOTNETCORE2
        )
        result = self.lambda_client.invoke(
            FunctionName=TEST_LAMBDA_NAME_DOTNETCORE2, Payload=b'{}')
        result_data = result['Payload'].read()
        self.assertEqual(result['StatusCode'], 200)
        self.assertEqual(to_str(result_data).strip(), '{}')
        
        expected = ['Running .NET Core 2.0 Lambda']