Last active
December 4, 2015 05:06
-
-
Save johnjansen/079536f6e93dd066b1ec to your computer and use it in GitHub Desktop.
AWS Lambda, Publish an SNS Message — Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package blahblah; | |
import scala.collection.JavaConverters._ | |
import java.net.URLDecoder | |
import com.amazonaws.services.lambda.runtime.Context | |
import com.amazonaws.services.sns.AmazonSNSClient | |
import com.amazonaws.services.sns.model.PublishRequest | |
import java.io.{InputStream, OutputStream, PrintStream} | |
class Main { | |
val topicArn = "arn:aws:sns:us-west-2:xxxxxxxxxxxx:some_topic" | |
val snsClient = new AmazonSNSClient() | |
snsClient.setRegion(Region.getRegion(Regions.US_WEST_2)); | |
// receive an event, and publish to SNS | |
def scheduled(input: InputStream, output: OutputStream, context:Context): Unit = { | |
val publishRequest = new PublishRequest(topicArn, item_url.toString) | |
val publishResult = snsClient.publish(publishRequest) | |
log(publishResult.getMessageId() + " >> " + item_url.toString) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment