public async Task Invoke(string name, object parameter) { await amazonLambdaClient.InvokeAsync(new InvokeRequest() { FunctionName = name, Payload = JsonConvert.SerializeObject(parameter), InvocationType = InvocationType.Event }); }
/// <summary> /// This method is called for every Lambda invocation. This method takes in an S3 event object and can be used /// to respond to S3 notifications. /// </summary> /// <param name="evnt"></param> /// <param name="context"></param> /// <returns></returns> public async Task <string> FunctionHandler(S3Event evnt, ILambdaContext context) { var s3Event = evnt.Records?[0].S3; if (s3Event == null) { return(null); } try { var client = new AmazonLambdaClient(); var logProcessName = System.Environment.GetEnvironmentVariable("LOGPROCESS_NAME"); var analysisLogProcessName = System.Environment.GetEnvironmentVariable("ANALYSIS_LOGPROCESS_NAME"); Console.WriteLine($"logProcessName: {logProcessName}"); Console.WriteLine($"analysisLogProcessName: {analysisLogProcessName}"); var logRequest = new InvokeRequest { FunctionName = logProcessName, InvocationType = InvocationType.Event, Payload = Newtonsoft.Json.JsonConvert.SerializeObject(evnt) }; var analysisLogRequest = new InvokeRequest { FunctionName = analysisLogProcessName, InvocationType = InvocationType.Event, Payload = Newtonsoft.Json.JsonConvert.SerializeObject(evnt) }; var logResponse = await client.InvokeAsync(logRequest); Console.WriteLine($"LogProcess response.StatusCode: {JsonConvert.SerializeObject(logResponse.StatusCode)}"); var analysisLogResponse = await client.InvokeAsync(analysisLogRequest); Console.WriteLine($"AnalysisLogProcess response.StatusCode: {JsonConvert.SerializeObject(analysisLogResponse.StatusCode)}"); return($"{s3Event.Bucket.Name}:{s3Event.Object.Key}"); } catch (Exception e) { context.Logger.LogLine($"Error getting object {s3Event.Object.Key} from bucket {s3Event.Bucket.Name}. Make sure they exist and your bucket is in the same region as this function."); context.Logger.LogLine(e.Message); context.Logger.LogLine(e.StackTrace); throw; } }
/* * 継承先のHandlerのreturn直前で * Task.WaitAll(PostProcess(m_data, context)); * とすること。 * * @todo エラーハンドリング * https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/API_Invoke.html */ protected async Task PostProcess(T_ARG data, ILambdaContext ctx) { // 環境変数から、呼び出すLambda名をFIX var env = System.Environment.GetEnvironmentVariable("LAMBDA_ENV"); var service = System.Environment.GetEnvironmentVariable("LAMBDA_SERVICE"); if ((data.postLambda == "") || (env == null) || (service == null)) { return; } var funcName = service + "-" + env + "-" + data.postLambda; ctx.Log("PostProcess Lambda : " + funcName); // base64endoed json を decode して jsonとして引数にセット var payload = new PostLambdaArg() { role = "server", mode = data.postLambdaMode, dataBody = data.postLambdaArg }; using (var client = new AmazonLambdaClient(Amazon.RegionEndpoint.APNortheast1)) { // base64endoed => json をそのままバイパス if (data.isWaitPostProcess) { var request = new InvokeRequest() { FunctionName = funcName, InvocationType = InvocationType.RequestResponse, Payload = JsonSerializer.ToJsonString(payload) }; var response = await client.InvokeAsync(request); } else { var request = new InvokeRequest() { FunctionName = funcName, InvocationType = InvocationType.Event, Payload = JsonSerializer.ToJsonString(payload) }; var response = await client.InvokeAsync(request); } } }
public static string CallMethod(string functionName, string json) { Console.WriteLine(Utils.CurrentMethod); InvokeRequest request = new InvokeRequest { FunctionName = functionName, InvocationType = "RequestResponse", LogType = "Tail", Payload = json }; Task <InvokeResponse> t = client.InvokeAsync(request); t.Wait(30000); InvokeResponse response = t.Result; MemoryStream ps = response.Payload; StreamReader reader = new StreamReader(ps); string payload = reader.ReadToEnd(); Console.WriteLine(">>> Calling Function : " + functionName); Console.WriteLine(payload); Console.WriteLine(); Console.WriteLine(">>> Status Code : " + response.StatusCode); string logs = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(response.LogResult)); Console.WriteLine(logs); Console.WriteLine(response.FunctionError); return(payload); }
public async Task <Simulate> Run(SimulateParams simulateParams) { using (var client = new AmazonLambdaClient(RegionEndpoint.USEast2)) { var apirequest = new APIGatewayProxyRequest() { QueryStringParameters = new Dictionary <string, string>() }; foreach (PropertyInfo param in simulateParams.GetType().GetProperties()) { apirequest.QueryStringParameters.Add(param.Name, param.GetValue(simulateParams).ToString()); } var request = new InvokeRequest { FunctionName = "simulate", Payload = JsonConvert.SerializeObject(apirequest) }; var response = await client.InvokeAsync(request); string result; using (var sr = new StreamReader(response.Payload)) { result = sr.ReadToEnd(); SimulateHttpResponse httpResponse = JsonConvert.DeserializeObject <SimulateHttpResponse>(result); Simulate simulation = JsonConvert.DeserializeObject <Simulate>(httpResponse.Body); return(simulation); } } }
public override void ViewDidLoad() { base.ViewDidLoad(); CognitoAWSCredentials credentials = new CognitoAWSCredentials( "ap-southeast-2:b3abd62e-3efc-4d68-998e-7e528afc3368", // Cognito Identity Pool ID RegionEndpoint.APSoutheast2 // Region ); Amazon.Lambda.Model.InvokeRequest request = new Amazon.Lambda.Model.InvokeRequest(); request.FunctionName = "TestTT"; request.Payload = "{\"id\":1,\"operation\":\"list\",\"tableName\":\"TimeTrackDB\",\"username\":\"" + User + "\",\"client\":\"" + "a" + "\",\"charge\":\"" + "a" + "\",\"starttime\":\"" + DateTime.Now + "\",\"stoptime\":\"" + DateTime.Now + "\"}"; Amazon.Lambda.AmazonLambdaClient client = new AmazonLambdaClient(credentials, RegionEndpoint.APSoutheast2); var result = client.InvokeAsync(request).Result; result.Payload.Position = 0; var sr = new StreamReader(result.Payload); var myStr = sr.ReadToEnd(); var data = JsonConvert.DeserializeObject <LogTimes>(myStr); tblLogTimeData.Source = new LogTimeData(data.Items); }
public async Task <bool> IsValidUser(string filePath, string fileName) { RekognitionIsValidUserResponse response = new RekognitionIsValidUserResponse { ResponseCode = await UploadToS3(filePath, fileName) }; AmazonLambdaClient amazonLambdaClient = new AmazonLambdaClient(accessKey, secretKey, Amazon.RegionEndpoint.EUCentral1); InvokeRequest lambdaRequest = new InvokeRequest { InvocationType = InvocationType.RequestResponse, FunctionName = "dyFaceRekognition", Payload = "\"" + fileName + "\"" }; //remove file var result = await amazonLambdaClient.InvokeAsync(lambdaRequest); var lambdaResponse = Encoding.ASCII.GetString(result.Payload.ToArray()); //include error handling if (bool.TryParse(lambdaResponse, out bool returnValue)) { return(returnValue); } //return error message saying that there was an issue return(false); }
private async Task NotifySubscribers(Subscription[] subscribers, Event @event) { using (var client = new AmazonLambdaClient()) { foreach (var subscriber in subscribers) { var request = new InvokeRequest { FunctionName = notifierFunctionResolver.GetNotifierFunction(), Payload = JsonConvert.SerializeObject(new LambdaInvocationPayload() { CompressedEvent = JsonConvert.SerializeObject(@event).ToCompressedBase64String(), Subscription = subscriber }), InvocationType = InvocationType.Event }; Console.WriteLine($"NotifySubscriber MessageId: {@event.Message.Header.MessageId} Subscriber: {subscriber.Type}:{subscriber.Endpoint}"); var response = await client.InvokeAsync(request); Console.WriteLine($"NotifySubscriberResponse MessageId: {@event.Message.Header.MessageId} Subscriber: {subscriber.Type}:{subscriber.Endpoint} Response Code: {response.StatusCode}"); if (response.StatusCode > 299) { Console.WriteLine($"MessageId: {@event.Message.Header.MessageId} Subscriber: {subscriber.Type}:{subscriber.Endpoint} Error: {response}"); } } } }
public async Task FunctionHandler(JObject input, ILambdaContext context) { while (true) { ReceiveMessageRequest request = new ReceiveMessageRequest { QueueUrl = InputQueueUrl, MaxNumberOfMessages = 1 }; var result = await this.SqSClient.ReceiveMessageAsync(request : request); if (result.Messages == null) { continue; } await this.ProcessMessage(message : result.Messages.First(), context : context); break; } var invokeLambdaRequest = new InvokeRequest { FunctionName = "arn:aws:lambda:us-east-2:628654266155:function:MessageQueueRecursiveListener", InvocationType = InvocationType.Event, }; context.Logger.Log(message: " !! calling now another instance of lambda asynchronously !! "); var lambdaClient = new AmazonLambdaClient(); var lambdaCall = await lambdaClient.InvokeAsync(request : invokeLambdaRequest); }
public static async Task <string> InvokeAWSLambda(string functionName, string payLoad, RegionEndpoint regionEndpoint) { try { if (!String.IsNullOrEmpty(functionName) && !String.IsNullOrEmpty(payLoad)) { var newPayload = new RoutingLambdaRequestModel() { body = payLoad }; var lambdaClient = new AmazonLambdaClient(IdentifierEnvironmentConstants.IdentifierConfigurations.RoutingLambdaCredentials.AccessKey, IdentifierEnvironmentConstants.IdentifierConfigurations.RoutingLambdaCredentials.Secret, regionEndpoint); var response = await lambdaClient.InvokeAsync(new InvokeRequest { FunctionName = functionName, InvocationType = InvocationType.RequestResponse, LogType = LogType.None, Payload = JsonConvert.SerializeObject(newPayload) }); using (var reader = response.Payload) { return(new StreamReader(reader).ReadToEnd()); } } } catch (Exception ex) { throw ex; } return(null); }
public InvokeResponse Invoke(string functionName, string path, string data) { JObject pathParams; var template_name = Path.Combine(System.Environment.CurrentDirectory, "WhooshRequestTemplate.json"); var fileData = File.ReadAllText(template_name); JObject payLoad = JObject.Parse(fileData); payLoad.Add("path", path); pathParams = (JObject)payLoad["pathParameters"]; pathParams.Add("key", data); var region_name = config.AwsRegionName; var env_id = "v8"; // var env_id = config.AwsNamespace; AmazonLambdaClient client = new AmazonLambdaClient(RegionEndpoint.GetBySystemName(region_name)); InvokeRequest request = new InvokeRequest() { FunctionName = $"PY-{env_id}", Payload = payLoad.ToString(), }; var response = client.InvokeAsync(request).GetAwaiter().GetResult(); return(response); }
public async Task <object> FunctionHandler(ILambdaContext context) { try { using (AmazonLambdaClient client = new AmazonLambdaClient(RegionEndpoint.APSoutheast1)) { var request = new Amazon.Lambda.Model.InvokeRequest { FunctionName = "test_call_rest_api", Payload = "" }; var response = await client.InvokeAsync(request); using (var sr = new StreamReader(response.Payload)) { var unit = JsonConvert.DeserializeObject(sr.ReadToEndAsync().Result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(unit); } } } catch (Exception ex) { return(ex.Message); } }
public async void ExecuteLambda() { Debug.Log("ExecuteLambda"); AmazonLambdaClient amazonLambdaClient = new AmazonLambdaClient(_authenticationManager.GetCredentials(), AuthenticationManager.Region); InvokeRequest invokeRequest = new InvokeRequest { FunctionName = _lambdaFunctionName, InvocationType = InvocationType.RequestResponse }; InvokeResponse response = await amazonLambdaClient.InvokeAsync(invokeRequest); Debug.Log("Response statusCode: " + response.StatusCode); if (response.StatusCode == 200) { Debug.Log("Successful lambda call"); // demonstrate we can get the users ID for use in our game string userId = _authenticationManager.GetUsersId(); Debug.Log("UserId in LambdaManager: " + userId); } }
public void TestLambdaInvokeSubsegmentContainsFunctionNameForAWSSDKHandler() { String temp_path = @"JSONs\AWSRequestInfoWithLambda.json"; //registering manifest file with Lambda AWSSDKHandler.RegisterXRayManifest(temp_path); var lambda = new AmazonLambdaClient(new AnonymousAWSCredentials(), RegionEndpoint.USEast1); CustomResponses.SetResponse(lambda, null, null, true); AWSXRayRecorder.Instance.BeginSegment("lambda", TraceId); #if NET45 lambda.Invoke(new InvokeRequest { FunctionName = "testFunction" }); #else lambda.InvokeAsync(new InvokeRequest { FunctionName = "testFunction" }).Wait(); #endif var segment = TraceContext.GetEntity(); AWSXRayRecorder.Instance.EndSegment(); Assert.AreEqual("Invoke", segment.Subsegments[0].Aws["operation"]); Assert.AreEqual("testFunction", segment.Subsegments[0].Aws["function_name"]); }
public static async Task ProcessNotificationAsync(ApiGatewayRequest request, McmaApiResponse response) { var table = new DynamoDbTable(request.StageVariables["TableName"]); var jobAssignmentId = request.StageVariables["PublicUrl"] + "/job-assignments/" + request.PathVariables["id"]; var jobAssignment = await table.GetAsync <JobAssignment>(jobAssignmentId); if (jobAssignment == null) { response.StatusCode = (int)HttpStatusCode.NotFound; response.StatusMessage = "No resource found on path '" + request.Path + "'"; return; } var notification = request.JsonBody?.ToMcmaObject <Notification>(); if (notification == null) { response.StatusCode = (int)HttpStatusCode.BadRequest; response.StatusMessage = "Missing notification in request body"; return; } var lambdaClient = new AmazonLambdaClient(); var invokeRequest = new InvokeRequest { FunctionName = request.StageVariables["WorkerLambdaFunctionName"], InvocationType = "Event", LogType = "None", Payload = new { action = "ProcessNotification", request = request, jobAssignmentId = jobAssignmentId, notification = notification }.ToMcmaJson().ToString() }; await lambdaClient.InvokeAsync(invokeRequest); }
public override async Task <APIGatewayProxyResponse> FunctionHandlerAsync(APIGatewayProxyRequest request, ILambdaContext lambdaContext) { Console.WriteLine("In overridden FunctionHandlerAsync..."); if (request.Resource == "WarmingLambda") { int.TryParse(request.Body, out var concurrencyCount); if (concurrencyCount > 1) { Console.WriteLine($"Warming instance {concurrencyCount}."); var client = new AmazonLambdaClient(); await client.InvokeAsync(new Amazon.Lambda.Model.InvokeRequest { FunctionName = lambdaContext.FunctionName, InvocationType = InvocationType.RequestResponse, Payload = JsonConvert.SerializeObject(new APIGatewayProxyRequest { Resource = request.Resource, Body = (concurrencyCount - 1).ToString() }) }); } return(new APIGatewayProxyResponse { }); } return(await base.FunctionHandlerAsync(request, lambdaContext)); }
async static Task InvokeViaSdk(Stream fileStream) { var lambdaConfig = new AmazonLambdaConfig { ServiceURL = "http://localhost:4566" }; using var lambda = new AmazonLambdaClient(lambdaConfig); using var memoryStream = new MemoryStream(); fileStream.CopyTo(memoryStream); var getFunctionRequest = new GetFunctionRequest { FunctionName = "ConverterTronStack-ConverterTronLambda-V6ZBU97Z5XM0" }; var invokeRequest = new InvokeRequest { FunctionName = "ConverterTronStack-ConverterTronLambda-V6ZBU97Z5XM0", InvocationType = InvocationType.RequestResponse, PayloadStream = memoryStream }; var getThings = await lambda.GetFunctionAsync(getFunctionRequest); var response = await lambda.InvokeAsync(invokeRequest); }
/// <summary> /// Amazon EventBridge event schedule rule to keep the Lambda/s warm /// Payload: { "RouteKey": "WarmingLambda", "Body": "3" } /// </summary> /// <param name="request"></param> /// <param name="lambdaContext"></param> /// <returns></returns> public override async Task <APIGatewayHttpApiV2ProxyResponse> FunctionHandlerAsync(APIGatewayHttpApiV2ProxyRequest request, ILambdaContext lambdaContext) { LambdaLogger.Log("In overridden FunctionHandlerAsync..."); if (request.RouteKey == "WarmingLambda") { int.TryParse(request.Body, out var concurrencyCount); if (concurrencyCount > 1) { LambdaLogger.Log($"Warming instance {concurrencyCount}."); var client = new AmazonLambdaClient(); await client.InvokeAsync(new InvokeRequest { FunctionName = lambdaContext.FunctionName, InvocationType = InvocationType.RequestResponse, Payload = JsonSerializer.Serialize(new APIGatewayHttpApiV2ProxyRequest { RouteKey = request.RouteKey, Body = (concurrencyCount - 1).ToString() }) }); } return(new APIGatewayHttpApiV2ProxyResponse()); } return(await base.FunctionHandlerAsync(request, lambdaContext)); }
public static async Task DeleteJobAsync(ApiGatewayRequest request, McmaApiResponse response) { Logger.Debug(nameof(DeleteJobAsync)); Logger.Debug(request.ToMcmaJson().ToString()); var table = new DynamoDbTable(request.StageVariables["TableName"]); var jobId = request.StageVariables["PublicUrl"] + request.Path; var job = await table.GetAsync <Job>(jobId); if (job == null) { response.StatusCode = (int)HttpStatusCode.NotFound; response.StatusMessage = "No resource found on path '" + request.Path + "'."; return; } await table.DeleteAsync <Job>(jobId); // invoking worker lambda function that will delete the JobProcess created for this Job if (!string.IsNullOrEmpty(job.JobProcess)) { var lambdaClient = new AmazonLambdaClient(); var invokeRequest = new InvokeRequest { FunctionName = request.StageVariables["WorkerLambdaFunctionName"], InvocationType = "Event", LogType = "None", Payload = new { action = "deleteJobProcess", request = request, jobProcessId = job.JobProcess }.ToMcmaJson().ToString() }; await lambdaClient.InvokeAsync(invokeRequest); } }
// ADD TO MIDDLE public async Task <string> WhatEmot(string filePath, string fileName) { Object emotResult = new ArrayList(); // Uploading file to S3 await UploadToS3(filePath, fileName); // Calling our Lambda function AmazonLambdaClient amazonLambdaClient = new AmazonLambdaClient(accessKey, privateKey, Amazon.RegionEndpoint.EUWest2); InvokeRequest ir = new InvokeRequest(); ir.InvocationType = InvocationType.RequestResponse; ir.FunctionName = "MyAWS"; // Selecting which file from S3 should our function use ir.Payload = "\"" + fileName + "\""; // Getting the result var result = await amazonLambdaClient.InvokeAsync(ir); // Picking up the result value string response = Encoding.ASCII.GetString(result.Payload.ToArray()); return(response); }
// ADD TO MIDDLE public async Task <bool> IsReferencePhotoValid(string filePath) { Object emotResult = new ArrayList(); // Uploading file to S3 await uploadReferencePhoto(filePath); // Calling our Lambda function AmazonLambdaClient amazonLambdaClient = new AmazonLambdaClient(accessKey, privateKey, Amazon.RegionEndpoint.EUWest2); InvokeRequest ir = new InvokeRequest(); ir.InvocationType = InvocationType.RequestResponse; ir.FunctionName = "IsReferencePhotoValid"; // Selecting which file from S3 should our function use ir.Payload = "\"" + "referencePhoto.jpg" + "\""; // Getting the result var resultAWS = await amazonLambdaClient.InvokeAsync(ir); // Picking up the result value string response = Encoding.ASCII.GetString(resultAWS.Payload.ToArray()); response = response.Replace("\"", ""); bool result = bool.Parse(response); if (result == false) { throw new InvalidReferencePictureException("test"); } return(bool.Parse(response)); }
public async Task <HttpResponseMessage> RunLambda(string awsEvent) { var lambdaRequest = new InvokeRequest { FunctionName = "scanCraigslist", Payload = awsEvent }; var response = await lambdaClient.InvokeAsync(lambdaRequest); if (response != null) { using (var sr = new StreamReader(response.Payload)) { string result = await sr.ReadToEndAsync(); JObject jobject = JObject.Parse(result); return(new HttpResponseMessage() { StatusCode = jobject["statusCode"].ToString() == "200" ? HttpStatusCode.OK : HttpStatusCode.BadRequest, Content = new StringContent(jobject["body"].ToString()) }); } } return(new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("") });; }
public async Task Given_valid_payload_when_lambda_invoked_synchronously_then_should_return_expected_response() { // Given var client = new AmazonLambdaClient(); var sqsEvent = new SQSEvent { Records = new List <SQSEvent.SQSMessage> { new SQSEvent.SQSMessage { Body = "Hello Lambda!" } } }; var request = new InvokeRequest { FunctionName = "1-direct-invocation", // force sync lambda invocation InvocationType = InvocationType.RequestResponse, LogType = LogType.Tail, Payload = JsonSerializer.Serialize(sqsEvent) }; // When var result = await client.InvokeAsync(request); // Then Assert.Null(result.FunctionError); using var sr = new StreamReader(result.Payload); var response = await sr.ReadToEndAsync(); Assert.Equal("HELLO LAMBDA!", response.Replace("\"", "")); }
public void FetchGameAndPlayerSession(Dictionary <string, string> payLoad) { //StartCoroutine(ConnectToServer()); AWSConfigs.AWSRegion = "ap-south-1"; // Your region here AWSConfigs.HttpClient = AWSConfigs.HttpClientOption.UnityWebRequest; // paste this in from the Amazon Cognito Identity Pool console CognitoAWSCredentials credentials = new CognitoAWSCredentials( "ap-south-1:633d62b0-bdef-4b2b-8b33-1e091db82f24", // Identity pool ID RegionEndpoint.APSouth1 // Region ); string payLoadString = MyDictionaryToJson(payLoad); AmazonLambdaClient client = new AmazonLambdaClient(loginClient.awsCredentials, RegionEndpoint.APSouth1); InvokeRequest request = new InvokeRequest { FunctionName = "TacticalCombatGetGS", InvocationType = InvocationType.RequestResponse, Payload = payLoadString }; loading = true; client.InvokeAsync(request, (response) => { if (response.Exception == null) { if (response.Response.StatusCode == 200) { var payload = Encoding.ASCII.GetString(response.Response.Payload.ToArray()) + "\n"; playerSessionObj = JsonUtility.FromJson <PlayerSessionObject>(payload); Debug.Log(playerSessionObj.PlayerSessionId); Debug.Log(playerSessionObj.IpAddress); Debug.Log(playerSessionObj.Port); Debug.Log(playerSessionObj); if (playerSessionObj.PlayerSessionId == null) { Debug.Log($"Error in Lambda: {payload}"); loading = false; } else { StartCoroutine(ConnectToServer()); //QForMainThread(ActionConnectToServer, playerSessionObj.IpAddress, Int32.Parse(playerSessionObj.Port), playerSessionObj.PlayerSessionId); } } else { loading = false; } } else { loading = false; Debug.LogError(response.Exception); } }); }
public async Task Can_invoke_simple_lambda_function() { var invokeRequest = new InvokeRequest { InvocationType = InvocationType.RequestResponse, Payload = "\"string\"", FunctionName = "ReverseStringFunction", }; var invokeResponse = await _lambdaClient.InvokeAsync(invokeRequest); invokeResponse.StatusCode.ShouldBe(200); invokeResponse.Payload.Length.ShouldBeGreaterThan(0); var streamReader = new StreamReader(invokeResponse.Payload); var payload = await streamReader.ReadToEndAsync(); payload.ShouldBe("\"gnirts\""); }
private Task TriggerLambda(string functionName) { using (AmazonLambdaClient client = new AmazonLambdaClient()) { return(client.InvokeAsync(new InvokeRequest { FunctionName = functionName })); } }
private async Task <InvokeResponse> InvokeFunctionAsync(AmazonLambdaClient lambdaClient, string payload) { var request = new InvokeRequest { FunctionName = FunctionName, Payload = payload }; return(await lambdaClient.InvokeAsync(request)); }
private async Task <InvokeResponse> InvokeFunctionAsync(string payload) { var request = new InvokeRequest { FunctionName = _functionName, Payload = string.IsNullOrEmpty(payload) ? null : payload }; return(await _lambdaClient.InvokeAsync(request)); }
public static async Task SendMessage(string payload) { var credentials = new BasicAWSCredentials(Environment.AccessKey, Environment.SecretKey); var client = new AmazonLambdaClient(credentials, RegionEndpoint.EUCentral1); var request = new InvokeRequest() { FunctionName = "PublishMessage", Payload = payload }; var response = await client.InvokeAsync(request); }
private async UniTask <InvokeResponse> InvokeLambdaFunctionAsync(AmazonLambdaClient lambdaClient, string functionName, InvocationType invocationType, string payload = "") { var request = new InvokeRequest { FunctionName = functionName, InvocationType = invocationType, Payload = payload, }; return(await lambdaClient.InvokeAsync(request)); }