List of usage examples for com.amazonaws.services.sns AmazonSNSClient AmazonSNSClient
@Deprecated
public AmazonSNSClient()
From source file:ch.admin.isb.hermes5.tools.filebackup.FileBackup.java
License:Apache License
private AmazonSNS sns(String accessKey, String secretKey, String snsEndpoint) { AmazonSNS sns = accessKey == null || "".equals(accessKey) ? new AmazonSNSClient() : new AmazonSNSClient(new BasicAWSCredentials(accessKey, secretKey)); sns.setEndpoint(snsEndpoint);/*from w w w .ja v a2s .c o m*/ return sns; }
From source file:com.github.abhinavmishra14.aws.glacier.service.impl.GlacierArchiveServiceImpl.java
License:Open Source License
/** * The Constructor.<b/>/* w ww. j a v a 2 s . c o m*/ * This Constructor will return glacier client if IAM role is enabled.<br/> * Additionally it will set the given endPoint for performing upload operation over vault.<br/> * Default endpoint will be always: "https://glacier.us-east-1.amazonaws.com/" * SSL Certificate checking will be disabled based on provided flag. * * @param disableCertCheck the disable cert check * @param endpoint the endpoint */ public GlacierArchiveServiceImpl(final boolean disableCertCheck, final String endpoint) { super(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("GlacierArchiveServiceImpl is initializing using IAM Role.."); } glacierClient = new AmazonGlacierClient(); //Get IAM Based glacier client sqsClient = new AmazonSQSClient(); snsClient = new AmazonSNSClient(); if (disableCertCheck) { System.setProperty(DISABLE_CERT_PARAM, TRUE);//Disable cert check } if (StringUtils.isNotBlank(endpoint)) { glacierClient.setEndpoint(endpoint); } }
From source file:com.netflix.metacat.main.services.notifications.sns.SNSNotificationServiceImplProvider.java
License:Apache License
/** * {@inheritDoc}/* w ww . j av a 2 s .com*/ */ @Override public NotificationService get() { if (this.config.isSnsNotificationEnabled()) { final String tableArn = this.config.getSnsTopicTableArn(); if (StringUtils.isEmpty(tableArn)) { throw new ProvisionException( "SNS Notifications are enabled but no table ARN provided. Unable to configure."); } final String partitionArn = this.config.getSnsTopicPartitionArn(); if (StringUtils.isEmpty(partitionArn)) { throw new ProvisionException( "SNS Notifications are enabled but no partition ARN provided. Unable to configure."); } log.info("SNS notifications are enabled. Providing SNSNotificationServiceImpl implementation."); final Retryer<PublishResult> retry = RetryerBuilder.<PublishResult>newBuilder() .retryIfExceptionOfType(InternalErrorException.class) .retryIfExceptionOfType(ThrottledException.class) .withWaitStrategy(WaitStrategies.incrementingWait(10, TimeUnit.SECONDS, 30, TimeUnit.SECONDS)) .withStopStrategy(StopStrategies.stopAfterAttempt(3)).build(); return new SNSNotificationServiceImpl(new AmazonSNSClient(), tableArn, partitionArn, this.mapper, retry); } else { log.info("SNS notifications are not enabled. Ignoring and providing default implementation."); return new DefaultNotificationServiceImpl(); } }
From source file:com.nextdoor.bender.aws.AmazonSNSClientFactory.java
License:Apache License
public AmazonSNSClient newInstance() { return new AmazonSNSClient(); }
From source file:com.nextdoor.bender.S3SnsNotifier.java
License:Apache License
public static void main(String[] args) throws ParseException, InterruptedException, IOException { formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZoneUTC(); /*//w w w.j a va 2s.com * Parse cli arguments */ Options options = new Options(); options.addOption(Option.builder().longOpt("bucket").hasArg().required() .desc("Name of S3 bucket to list s3 objects from").build()); options.addOption(Option.builder().longOpt("key-file").hasArg().required() .desc("Local file of S3 keys to process").build()); options.addOption( Option.builder().longOpt("sns-arn").hasArg().required().desc("SNS arn to publish to").build()); options.addOption(Option.builder().longOpt("throttle-ms").hasArg() .desc("Amount of ms to wait between publishing to SNS").build()); options.addOption(Option.builder().longOpt("processed-file").hasArg() .desc("Local file to use to store procssed S3 object names").build()); options.addOption(Option.builder().longOpt("skip-processed").hasArg(false) .desc("Whether to skip S3 objects that have been processed").build()); options.addOption( Option.builder().longOpt("dry-run").hasArg(false).desc("If set do not publish to SNS").build()); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); String bucket = cmd.getOptionValue("bucket"); String keyFile = cmd.getOptionValue("key-file"); String snsArn = cmd.getOptionValue("sns-arn"); String processedFile = cmd.getOptionValue("processed-file", null); boolean skipProcessed = cmd.hasOption("skip-processed"); dryRun = cmd.hasOption("dry-run"); long throttle = Long.parseLong(cmd.getOptionValue("throttle-ms", "-1")); if (processedFile != null) { File file = new File(processedFile); if (!file.exists()) { logger.debug("creating local file to store processed s3 object names: " + processedFile); file.createNewFile(); } } /* * Import S3 keys that have been processed */ if (skipProcessed && processedFile != null) { try (BufferedReader br = new BufferedReader(new FileReader(processedFile))) { String line; while ((line = br.readLine()) != null) { alreadyPublished.add(line.trim()); } } } /* * Setup writer for file containing processed S3 keys */ FileWriter fw = null; BufferedWriter bw = null; if (processedFile != null) { fw = new FileWriter(processedFile, true); bw = new BufferedWriter(fw); } /* * Create clients */ AmazonS3Client s3Client = new AmazonS3Client(); AmazonSNSClient snsClient = new AmazonSNSClient(); /* * Get S3 object list */ try (BufferedReader br = new BufferedReader(new FileReader(keyFile))) { String line; while ((line = br.readLine()) != null) { String key = line.trim(); if (alreadyPublished.contains(key)) { logger.info("skipping " + key); } ObjectMetadata om = s3Client.getObjectMetadata(bucket, key); S3EventNotification s3Notification = getS3Notification(key, bucket, om.getContentLength()); String json = s3Notification.toJson(); /* * Publish to SNS */ if (publish(snsArn, json, snsClient, key) && processedFile != null) { bw.write(key + "\n"); bw.flush(); } if (throttle != -1) { Thread.sleep(throttle); } } } if (processedFile != null) { bw.close(); fw.close(); } }
From source file:com.nike.cerberus.operation.gateway.CreateCloudFrontSecurityGroupUpdaterLambdaOperation.java
License:Apache License
@Inject public CreateCloudFrontSecurityGroupUpdaterLambdaOperation(final CloudFormationService cloudFormationService, final EnvironmentMetadata environmentMetadata, @Named(CF_OBJECT_MAPPER) final ObjectMapper cloudformationObjectMapper, AWSLambda awsLambda, AmazonS3 amazonS3) {//from ww w .jav a 2 s. c o m this.cloudFormationService = cloudFormationService; this.cloudformationObjectMapper = cloudformationObjectMapper; this.environmentMetadata = environmentMetadata; this.awsLambda = awsLambda; this.amazonS3 = amazonS3; final Region region = Region.getRegion(Regions.US_EAST_1); AmazonCloudFormation amazonCloudFormation = new AmazonCloudFormationClient(); amazonCloudFormation.setRegion(region); amazonSNS = new AmazonSNSClient(); amazonSNS.setRegion(region); }
From source file:dsmwatcher.DSMWatcher.java
License:Open Source License
public void notifyAdmin(Instance instance, ArrayList<String> violations, Boolean remediated) throws Exception { AmazonSNSClient snsClient = new AmazonSNSClient().withRegion(region); String message = "The instance " + instance.getInstanceId() + " with IP address " + instance.getPrivateIpAddress() + " was found with the following violations:"; if (!remediated) { for (String reason : violations) message += "\n" + reason; if (enableIsolation) message += "\nEnforcement is enabled and the instance has been isolated"; else/*from ww w . j av a2 s . c o m*/ message += "\nEnforcement is disabled - no action was taken"; } else message = "The instance " + instance.getInstanceId() + " with IP address " + instance.getPrivateIpAddress() + " is no longer in violation of any policies and has been removed from isolation"; PublishRequest publishRequest = new PublishRequest(topicARN, message); snsClient.publish(publishRequest); }
From source file:eu.openg.aws.sns.SNSService.java
License:Apache License
public SNSService() { this(new AmazonSNSClient()); }
From source file:jp.classmethod.aws.brian.config.AwsConfiguration.java
License:Apache License
@Bean public AmazonSNS sns() { AmazonSNSClient sns = new AmazonSNSClient(); sns.setRegion(region().getObject()); return sns; }