public async Task <IActionResult> Post([FromBody] LambdaMessage message) { var json = JsonConvert.SerializeObject(message); var topicArn = Configuration[Constants.Keys.TopicArn]; var result = await SNSClient.PublishAsync(topicArn, json); Logger.LogInformation($"Published SNS Topic. Message Id: {result.MessageId}"); return(StatusCode((int)result.HttpStatusCode, result.MessageId)); }
public void SubscribeTopic(string topicArn, string protocol, string endPoint) { SNSClient.SubscribeAsync(new SubscribeRequest() { TopicArn = topicArn, Protocol = protocol, Endpoint = endPoint }); }
public void PublishMessageToTopic(string subject, string message, string topicArn) { SNSClient.PublishAsync(new PublishRequest() { Subject = subject, Message = message, TopicArn = topicArn }); }
public Function() { _configuration = new ConfigurationBuilder() .AddEnvironmentVariables() .Build(); _appConfig = new AppConfig(); _configuration.Bind(_appConfig); Console.WriteLine(JsonConvert.SerializeObject(_appConfig)); _snsClient = new SNSClient(new BasicAWSCredentials(_appConfig.SNSAccessKey, _appConfig.SNSSecretKey), RegionEndpoint.GetBySystemName(_appConfig.SNSRegion), _appConfig.SNSTopic); }
private async Task <bool> NotifyStatus(Guid id, ILambdaLogger logger) { try { var topic = await SNSClient.FindTopicAsync(Config.GetSection("SimpleNotificationServiceTopic").Value); if (topic != null) { await SNSClient.PublishAsync(topic.TopicArn, $"Batch job will be scheduled for {id}").ConfigureAwait(false); } } catch (Exception ex) { logger.LogLine("error on sending status"); logger.LogLine(ex.Message); logger.LogLine(ex.StackTrace); throw; } return(true); }