@Override public void run(Webhook webhook, String login, String email, String name, String subject, String content) { SNSWebhookApp webhookApp = (SNSWebhookApp) webhook.getWebhookApp(); String topicArn = webhookApp.getTopicArn(); String awsAccount = webhookApp.getAwsAccount(); String awsSecret = webhookApp.getAwsSecret(); String region = webhookApp.getRegion(); AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials(awsAccount, awsSecret)); snsClient.setRegion(Region.getRegion(Regions.fromName(region))); try { PublishRequest publishReq = new PublishRequest() .withTopicArn(topicArn) .withMessage(getMessage(login, email, name, subject, content)); snsClient.publish(publishReq); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Cannot send notification to SNS service", e); } finally { LOGGER.log(Level.INFO, "Webhook runner terminated"); } }
public static boolean publish(String arn, String msg, AmazonSNSClient snsClient, String s3Key) { if (dryRun) { logger.warn("would have published " + s3Key + " S3 creation event to SNS"); return true; } logger.info("publishing " + s3Key + " S3 creation event to SNS"); try { snsClient.publish(arn, msg, "Amazon S3 Notification"); } catch (RuntimeException e) { logger.error("error publishing", e); return false; } return true; }
@Inject public CreateCloudFrontSecurityGroupUpdaterLambdaOperation(final CloudFormationService cloudFormationService, final EnvironmentMetadata environmentMetadata, @Named(CF_OBJECT_MAPPER) final ObjectMapper cloudformationObjectMapper, AWSLambda awsLambda, AmazonS3 amazonS3) { 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); }
private static AmazonSNS getSNS() throws IOException { String awsAccessKey = System.getProperty("AWS_ACCESS_KEY_ID"); // "YOUR_AWS_ACCESS_KEY"; String awsSecretKey = System.getProperty("AWS_SECRET_KEY"); // "YOUR_AWS_SECRET_KEY"; if (awsAccessKey == null) awsAccessKey = AWS_ACCESS_KEY; if (awsSecretKey == null) awsSecretKey = AWS_SECRET_KEY; AWSCredentials credentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey); AmazonSNS sns = new AmazonSNSClient(credentials); sns.setEndpoint("https://sns.us-west-2.amazonaws.com"); return sns; }
public static void assertNoStaleTopic(AmazonSNSClient client, String when) { /* Remove the topic created by the the old version of this test. Note that this may break the old tests running * in parallel. */ client.listTopics().getTopics().stream() .filter(topic -> topic.getTopicArn().endsWith("MyNewTopic")) .forEach(t -> client.deleteTopic(t.getTopicArn())); List<String> staleInstances = client.listTopics().getTopics().stream() // .map(topic -> topic.getTopicArn().substring(topic.getTopicArn().lastIndexOf(':') + 1)) // extract the // topic name // from the ARN .filter(name -> !name.startsWith(SNSIntegrationTest.class.getSimpleName()) || System.currentTimeMillis() - AWSUtils.toEpochMillis(name) > AWSUtils.HOUR) // .collect(Collectors.toList()); Assert.assertEquals(String.format("Found stale SNS topics %s running the test: %s", when, staleInstances), 0, staleInstances.size()); }
@Override protected void createAWSClient() { client = tryClientFactory(config.clientFactoryMethod, AmazonSNS.class, true); if ((client == null) && (config.clientEndpoint == null)) { client = tryClientFactory("com.amazonaws.services.sns.AmazonSNSClientBuilder.defaultClient", AmazonSNS.class, false); } if (client == null) { LogLog.debug(getClass().getSimpleName() + ": creating service client via constructor"); client = tryConfigureEndpointOrRegion(new AmazonSNSClient(), config.clientEndpoint); } }
/** * Sends using the sns publisher */ @Override public boolean postMessage(NotificationMessage nMsg, BasicSubscriber subscriber) { SNSSubscriber sub; if (subscriber instanceof SNSSubscriber) { sub = (SNSSubscriber) subscriber; } else { throw new ClassCastException("invalid subscriber " + subscriber.getClass().getName()); } SNSMessage msg = buildSNSMessage(nMsg); AmazonSNS sns = new AmazonSNSClient(new BasicAWSCredentials(sub.getAwsAccessKey(), sub.getAwsSecretKey())); if (sub.getSnsEndpoint() != null) { sns.setEndpoint(sub.getSnsEndpoint()); } CreateTopicRequest tRequest = new CreateTopicRequest(); tRequest.setName(msg.getTopicName()); CreateTopicResult result = sns.createTopic(tRequest); PublishRequest pr = new PublishRequest(result.getTopicArn(), msg.getTxtMessage()).withSubject(msg.getSubject()); try { PublishResult pubresult = sns.publish(pr); logger.info("Published msg with id - " + pubresult.getMessageId()); } catch (AmazonClientException ace) { logger.error(ace.getMessage()); return false; } return true; }
@Override public void onException(Exception e) { /* * Always close the iterator to prevent connection leaking */ try { if (this.recordIterator != null) { this.recordIterator.close(); } } catch (IOException e1) { logger.error("unable to close record iterator", e); } if (this.config == null || this.config.getHandlerConfig() == null) { return; } /* * Notify SNS topic */ SNSS3HandlerConfig handlerConfig = (SNSS3HandlerConfig) this.config.getHandlerConfig(); if (handlerConfig.getSnsNotificationArn() != null) { AmazonSNSClient snsClient = this.snsClientFactory.newInstance(); snsClient.publish(handlerConfig.getSnsNotificationArn(), this.inputFiles.stream().map(Object::toString).collect(Collectors.joining(",")), "SNSS3Handler Failed"); } }
@Test public void testExceptionHandlingd() throws Throwable { BaseHandler.CONFIG_FILE = "/com/nextdoor/bender/handler/config_test_sns.json"; TestContext ctx = new TestContext(); ctx.setFunctionName("unittest"); ctx.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test-function:staging"); /* * Invoke handler */ SNSS3Handler fhandler = (SNSS3Handler) getHandler(); fhandler.init(ctx); IpcSenderService ipcSpy = spy(fhandler.getIpcService()); doThrow(new TransportException("expected")).when(ipcSpy).shutdown(); fhandler.setIpcService(ipcSpy); AmazonSNSClient mockClient = mock(AmazonSNSClient.class); AmazonSNSClientFactory mockClientFactory = mock(AmazonSNSClientFactory.class); doReturn(mockClient).when(mockClientFactory).newInstance(); fhandler.snsClientFactory = mockClientFactory; SNSEvent event = getTestEvent(); try { fhandler.handler(event, ctx); } catch (Exception e) { } verify(mockClient, times(1)).publish("foo", "basic_input.log", "SNSS3Handler Failed"); }
@Provides @Singleton protected AmazonSNS provideAmazonSNS(Region region, AWSCredentialsProvider credentialsProvider) { AmazonSNS amazonSNS = new AmazonSNSClient(credentialsProvider); amazonSNS.setRegion(region); return amazonSNS; }
private void init() { AWSCredentials awsCredentials = new BasicAWSCredentials(configuration.getAccessKeyId(), configuration.getSecretAccessKey()); AWSStaticCredentialsProvider credProvider = new AWSStaticCredentialsProvider(awsCredentials); AmazonSNS sns = AmazonSNSClient.builder() .withCredentials(credProvider) .withRegion(configuration.getRegion()) .build(); this.snsMessageHandler = new SnsMessageHandler(sns); }
/** * Binds all the Amazon services used. */ @Override protected void configure() { final Region region = Region.getRegion(Regions.fromName(regionName)); bind(AmazonEC2.class).toInstance(createAmazonClientInstance(AmazonEC2Client.class, region)); bind(AmazonCloudFormation.class).toInstance(createAmazonClientInstance(AmazonCloudFormationClient.class, region)); bind(AmazonIdentityManagement.class).toInstance(createAmazonClientInstance(AmazonIdentityManagementClient.class, region)); bind(AWSKMS.class).toInstance(createAmazonClientInstance(AWSKMSClient.class, region)); bind(AmazonS3.class).toInstance(createAmazonClientInstance(AmazonS3Client.class, region)); bind(AmazonAutoScaling.class).toInstance(createAmazonClientInstance(AmazonAutoScalingClient.class, region)); bind(AWSSecurityTokenService.class).toInstance(createAmazonClientInstance(AWSSecurityTokenServiceClient.class, region)); bind(AWSLambda.class).toInstance(createAmazonClientInstance(AWSLambdaClient.class, region)); bind(AmazonSNS.class).toInstance(createAmazonClientInstance(AmazonSNSClient.class, region)); }
public String handleRequest(Context context) throws IOException { LambdaLogger logger = context.getLogger(); logger.log("handleRequest start."); ObjectMapper mapper = new ObjectMapper(); JsonObject json = mapper.readValue(new URL(IP_RANGE_URL), JsonObject.class); AmazonS3Client s3 = getS3Client(); Properties props = getProperties(); s3.setEndpoint(props.getProperty("s3.endpoint")); GetObjectRequest request = new GetObjectRequest(props.getProperty(S3_BUCKETNAME_KEY), CHECKED_FILE_NAME); try { S3Object beforeObject = s3.getObject(request); InputStream is = beforeObject.getObjectContent(); JsonObject beforeJson = mapper.readValue(is, JsonObject.class); Optional<String> diff = beforeJson.getDiff(json); if (diff.isPresent()) { AmazonSNSClient sns = getSNSClient(); sns.setRegion(Region.getRegion(Regions.fromName(props.getProperty("sns.region")))); PublishRequest publishRequest = new PublishRequest(props.getProperty("sns.topic.arn"), diff.get(), SNS_SUBJECT); PublishResult result = sns.publish(publishRequest); logger.log("send sns message. messageId = " + result.getMessageId()); } } catch (AmazonS3Exception e) { logger.log("before checked-ip-ranges.json does not exist."); } storeCheckedIpRange(json); logger.log("stored checked-ip-ranges.json"); return "success"; }
private AmazonSNSClient getSNSClient() { Optional<AWSCredentials> credentials = getCredentials(); if (credentials.isPresent()) { return new AmazonSNSClient(credentials.get()); } else { return new AmazonSNSClient(new EnvironmentVariableCredentialsProvider()); } }
public CreateEndpointJob() { try { client = new AmazonSNSClient( new PropertiesCredentials( BatchCreatePlatformEndpointSample.class .getClassLoader() .getResourceAsStream(BatchCreatePlatformEndpointSample.AWSCREDENTIALSPROPERTIES_FILE))); } catch (Exception e) { System.err .println("[ERROR] Error opening file <" + BatchCreatePlatformEndpointSample.AWSCREDENTIALSPROPERTIES_FILE + ">" + " " + e.getMessage()); System.exit(BatchCreatePlatformEndpointSample.CREDENTIAL_RETRIEVAL_FAILURE_ERROR_CODE); } }
private void factory() { ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.HTTP); if (isProxyMode()) { log.info("======AWS run in proxy mode." + getProxyHost() + ":" + getProxyPort() + "======"); System.err.println("======AWS run in proxy mode." + getProxyHost() + ":" + getProxyPort() + "======"); clientConfig.setProxyHost(getProxyHost()); clientConfig.setProxyPort(getProxyPort()); if (getProxyUsername() != null && getProxyUsername().length() > 0) clientConfig.setProxyUsername(getProxyUsername()); if (getProxyPassword() != null && getProxyPassword().length() > 0) clientConfig.setProxyPassword(getProxyPassword()); } else { log.info("======AWS run in normal mode." + "======"); System.err.println("======AWS run in normal mode." + "======"); } credentialsProvider = this.createCredentialsProvider(); s3 = new AmazonS3Client(credentialsProvider, clientConfig); s3.setEndpoint(s3Endpoint); queue = new AmazonSQSClient(credentialsProvider, clientConfig); queue.setEndpoint(sqsEndpoint); sns = new AmazonSNSClient(credentialsProvider, clientConfig); sns.setEndpoint(snsEndpoint); dydbv2 = new AmazonDynamoDBClient(credentialsProvider, clientConfig); dydbv2.setEndpoint(dynamodbEndpoint); }
public SNSMobilePush(AmazonSNSClient client,Denuncia d) { this.client=client; client.setEndpoint("https://sns.us-west-2.amazonaws.com"); this.snsClientWrapper= new AmazonSNSClientWrapper(client,d); }
@Test public void parseInternal_minimalConfiguration_configuresHandlerMethodArgumentResolverWithAmazonSnsImplicitlyConfigured() throws Exception { //Arrange ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-minimal.xml", getClass()); //Act HandlerMethodArgumentResolver argumentResolver = context.getBean(HandlerMethodArgumentResolver.class); //Assert assertNotNull(argumentResolver); assertTrue(context.containsBean(getBeanName(AmazonSNSClient.class.getName()))); }
@Test public void parseInternal_customRegion_configuresHandlerMethodArgumentResolverWithAmazonSnsImplicitlyConfiguredAndCustomRegionSet() throws Exception { //Arrange ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-customRegion.xml", getClass()); //Act AmazonSNSClient snsClient = context.getBean(AmazonSNSClient.class); //Assert assertEquals(new URI("https", Region.getRegion(Regions.EU_WEST_1).getServiceEndpoint("sns"), null, null), ReflectionTestUtils.getField(snsClient, "endpoint")); }
@Test public void parseInternal_customRegionProvider_configuresHandlerMethodArgumentResolverWithAmazonSnsImplicitlyConfiguredAndCustomRegionSet() throws Exception { //Arrange ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-customRegionProvider.xml", getClass()); //Act AmazonSNSClient snsClient = context.getBean(AmazonSNSClient.class); //Assert assertEquals(new URI("https", Region.getRegion(Regions.US_WEST_2).getServiceEndpoint("sns"), null, null), ReflectionTestUtils.getField(snsClient, "endpoint")); }
@Test public void parseInternal_customSnsClient_configuresHandlerMethodArgumentResolverWithCustomSnsClient() throws Exception { //Arrange ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-customSnsClient.xml", getClass()); //Act AmazonSNSClient snsClient = context.getBean("customSnsClient", AmazonSNSClient.class); //Assert assertNotNull(snsClient); assertFalse(context.containsBean(getBeanName(AmazonSNSClient.class.getName()))); }
@Test public void parseInternal_withMinimalConfig_shouldCreateDefaultTemplate() throws Exception { //Arrange DefaultListableBeanFactory registry = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry); //Act reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-minimal.xml", getClass())); //Assert NotificationMessagingTemplate notificationMessagingTemplate = registry.getBean(NotificationMessagingTemplate.class); assertSame(registry.getBean(AmazonSNSClient.class), ReflectionTestUtils.getField(notificationMessagingTemplate, "amazonSns")); Object cachingDestinationResolverProxy = ReflectionTestUtils.getField(notificationMessagingTemplate, "destinationResolver"); Object targetDestinationResolver = ReflectionTestUtils.getField(cachingDestinationResolverProxy, "targetDestinationResolver"); assertEquals(registry.getBean(GlobalBeanDefinitionUtils.RESOURCE_ID_RESOLVER_BEAN_NAME), ReflectionTestUtils.getField(targetDestinationResolver, "resourceIdResolver")); assertTrue(CompositeMessageConverter.class.isInstance(notificationMessagingTemplate.getMessageConverter())); @SuppressWarnings("unchecked") List<MessageConverter> messageConverters = (List<MessageConverter>) ReflectionTestUtils.getField(notificationMessagingTemplate.getMessageConverter(), "converters"); assertEquals(2, messageConverters.size()); assertTrue(StringMessageConverter.class.isInstance(messageConverters.get(0))); assertTrue(MappingJackson2MessageConverter.class.isInstance(messageConverters.get(1))); StringMessageConverter stringMessageConverter = (StringMessageConverter) messageConverters.get(0); assertSame(String.class, stringMessageConverter.getSerializedPayloadClass()); assertEquals(false, ReflectionTestUtils.getField(stringMessageConverter, "strictContentTypeMatch")); MappingJackson2MessageConverter jackson2MessageConverter = (MappingJackson2MessageConverter) messageConverters.get(1); assertSame(String.class, jackson2MessageConverter.getSerializedPayloadClass()); assertEquals(false, ReflectionTestUtils.getField(jackson2MessageConverter, "strictContentTypeMatch")); }
@Test public void parseInternal_withCustomRegion_shouldConfigureDefaultClientWithCustomRegion() throws Exception { //Arrange DefaultListableBeanFactory registry = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry); //Act reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-custom-region.xml", getClass())); //Assert AmazonSNSClient amazonSns = registry.getBean(AmazonSNSClient.class); assertEquals("https://" + Region.getRegion(Regions.EU_WEST_1).getServiceEndpoint("sns"), ReflectionTestUtils.getField(amazonSns, "endpoint").toString()); }
@Test public void parseInternal_withCustomRegionProvider_shouldConfigureDefaultClientWithCustomRegionReturnedByProvider() throws Exception { //Arrange DefaultListableBeanFactory registry = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry); //Act reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-custom-region-provider.xml", getClass())); //Assert AmazonSNSClient amazonSns = registry.getBean(AmazonSNSClient.class); assertEquals("https://" + Region.getRegion(Regions.CN_NORTH_1).getServiceEndpoint("sns"), ReflectionTestUtils.getField(amazonSns, "endpoint").toString()); }
public ControlChannel(boolean callerIsMaster, String awsAccessKey, String awsSecretKey, String snsControlTopicName, String userAccountPrincipalId, String userARN, CCPayloadHandler ccPayloadHandler) throws Exception { super(); try { this.mySourceIp = InetAddress.getLocalHost().getHostAddress(); } catch(Exception e) { logger.error("Error getting local inet address: " + e.getMessage()); } mySourceIdentifier = determineHostName() + "-" +uuid; this.snsControlTopicName = snsControlTopicName; if (callerIsMaster) { canDestroyTopic = true; this.snsControlTopicName += "-" + mySourceIdentifier; } this.ccPayloadHandler = ccPayloadHandler; sqsClient = new AmazonSQSClient(new BasicAWSCredentials(awsAccessKey, awsSecretKey)); snsClient = new AmazonSNSClient(new BasicAWSCredentials(awsAccessKey, awsSecretKey)); this.connectToTopic(callerIsMaster, 1000, userAccountPrincipalId, userARN); }
public static AmazonSNSClient createNotificationClient() { BasicCredentialsProvider credentials = BasicCredentialsProvider.standard(); AmazonSNSClient client = !credentials.isValid() ? null : (AmazonSNSClient) AmazonSNSClientBuilder.standard() .withCredentials(credentials) .withRegion("eu-west-1") .build(); return client; }
/** * The Synchronous SNS client is used for creating topics and subscribing queues. */ private AmazonSNSClient createSNSClient( final Region region ) { final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider(); final AmazonSNSClient sns = new AmazonSNSClient( ugProvider.getCredentials(), clientConfiguration ); sns.setRegion( region ); return sns; }
public CreateEndpointJob() { try { client = new AmazonSNSClient( new PropertiesCredentials( BatchCreatePlatformEndpointSample.class .getResourceAsStream(BatchCreatePlatformEndpointSample.AWSCREDENTIALSPROPERTIES_FILE))); } catch (IOException ioe) { System.err .print("[ERROR] Error opening file" + BatchCreatePlatformEndpointSample.AWSCREDENTIALSPROPERTIES_FILE + ": " + ioe.getMessage()); System.exit(BatchCreatePlatformEndpointSample.CREDENTIAL_RETRIEVAL_FAILURE_ERROR_CODE); } }
public static void main(String[] args) throws IOException{ /* * TODO: Be sure to fill in your AWS access credentials in the * AwsCredentials.properties file before you try to run this sample. * http://aws.amazon.com/security-credentials */ AmazonSNS sns = new AmazonSNSClient(new PropertiesCredentials( SNSMobilePush.class .getResourceAsStream("AwsCredentials.properties"))); sns.setEndpoint("https://sns.us-west-2.amazonaws.com"); System.out.println("===========================================\n"); System.out.println("Getting Started with Amazon SNS"); System.out.println("===========================================\n"); try { SNSMobilePush sample = new SNSMobilePush(sns); // TODO: Uncomment the services you wish to use. //sample.demoAndroidAppNotification(Platform.GCM); //sample.demoKindleAppNotification(Platform.ADM); //sample.demoAppleAppNotification(Platform.APNS); //sample.demoAppleAppNotification(Platform.APNS_SANDBOX); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SNS, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out .println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SNS, such as not " + "being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
public AmazonSNSClient newInstance() { return new AmazonSNSClient(); }
public AmazonSNSClient getClient() { return client; }
public void setClient(AmazonSNSClient client) { this.client = client; }
public AmazonSNSClient getSnsClient() { return snsClient; }
public void setSnsClient(AmazonSNSClient snsClient) { this.snsClient = snsClient; }
protected AmazonSNS amazonSNSClient() { AmazonSNSClient snsClient = new AmazonSNSClient(amazonCredentialsProvider()); snsClient.setRegion(getRegion()); return snsClient; }
@Override protected AmazonSNS amazonSNSClient() { AmazonSNSClient snsClient = new AmazonSNSClient(awsCredentials()); snsClient.setRegion(getRegion()); return snsClient; }
public SNSService() { this(new AmazonSNSClient()); }
public static void main(String[] args) throws IOException { /* * TODO: Be sure to fill in your AWS access credentials in the * AwsCredentials.properties file before you try to run this sample. * http://aws.amazon.com/security-credentials */ AmazonSNS sns = new AmazonSNSClient(new PropertiesCredentials( SNSMobilePush.class .getResourceAsStream("AwsCredentials.properties"))); sns.setEndpoint("https://sns.us-west-2.amazonaws.com"); System.out.println("===========================================\n"); System.out.println("Getting Started with Amazon SNS"); System.out.println("===========================================\n"); try { SNSMobilePush sample = new SNSMobilePush(sns); /* TODO: Uncomment the services you wish to use. */ // sample.demoAndroidAppNotification(); // sample.demoKindleAppNotification(); // sample.demoAppleAppNotification(); // sample.demoAppleSandboxAppNotification(); // sample.demoBaiduAppNotification(); // sample.demoWNSAppNotification(); // sample.demoMPNSAppNotification(); } catch (AmazonServiceException ase) { System.out .println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SNS, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out .println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SNS, such as not " + "being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }