Exemplo n.º 1
0
 //Unfinished
 public void SetEventTrigger()
 {
     var lstLambdaFuncs = client.ListFunctions();
     var request        = new GetEventSourceMappingRequest()
     {
     };
     var policy = client.GetEventSourceMapping(request);
 }
Exemplo n.º 2
0
        public static string CreateEventSourceMapping(string eventSourceArn)
        {
            string uuid = "";

            try
            {
                AmazonLambdaClient lambdaClient;

                using (lambdaClient = new AmazonLambdaClient(Models.MyAWSConfigs.KinesisRegion))
                {
                    CreateEventSourceMappingRequest eventSourceMappingRequest = new CreateEventSourceMappingRequest
                    {
                        EventSourceArn = eventSourceArn,
                        BatchSize      = 100,
                        MaximumBatchingWindowInSeconds = 0,
                        StartingPosition = EventSourcePosition.LATEST,
                        Enabled          = true,
                        FunctionName     = MyAWSConfigs.LambdaFunctionName,
                    };
                    CreateEventSourceMappingResponse eventSourceMappingResponse = lambdaClient.CreateEventSourceMapping(eventSourceMappingRequest);

                    uuid = eventSourceMappingResponse.UUID;

                    string state = eventSourceMappingResponse.State;
                    while (state != "Enabled")
                    {
                        Thread.Sleep(1 * 1000);

                        GetEventSourceMappingRequest getRequest = new GetEventSourceMappingRequest
                        {
                            UUID = uuid,
                        };
                        GetEventSourceMappingResponse getResponse = lambdaClient.GetEventSourceMapping(getRequest);

                        state = getResponse.State;
                    }
                }
            }
            catch (AmazonLambdaException e)
            {
                Console.WriteLine("AmazonLambdaException: " + e);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
            }

            return(uuid);
        }