import cloudwatch = require('@aws-cdk/aws-cloudwatch'); import events = require('@aws-cdk/aws-events'); import iam = require('@aws-cdk/aws-iam'); import lambda = require('@aws-cdk/aws-lambda'); import s3n = require('@aws-cdk/aws-s3-notifications'); import sqs = require('@aws-cdk/aws-sqs'); import cdk = require('@aws-cdk/cdk'); import { TopicName } from './sns.generated'; import { Subscription, SubscriptionProtocol } from './subscription'; /** * ARN of a Topic */ export declare class TopicArn extends cdk.Arn { } /** * Either a new or imported Topic */ export declare abstract class TopicRef extends cdk.Construct implements events.IEventRuleTarget, cloudwatch.IAlarmAction, s3n.IBucketNotificationDestination { /** * Import a Topic defined elsewhere */ static import(parent: cdk.Construct, name: string, props: TopicRefProps): TopicRef; abstract readonly topicArn: TopicArn; abstract readonly topicName: TopicName; /** * Controls automatic creation of policy objects. * * Set by subclasses. */ protected abstract readonly autoCreatePolicy: boolean; private policy?; /** Buckets permitted to send notifications to this topic */ private readonly notifyingBuckets; /** * Indicates if the resource policy that allows CloudWatch events to publish * notifications to this topic have been added. */ private eventRuleTargetPolicyAdded; /** * Export this Topic */ export(): TopicRefProps; /** * Subscribe some endpoint to this topic */ subscribe(name: string, endpoint: string, protocol: SubscriptionProtocol): void; /** * Defines a subscription from this SNS topic to an SQS queue. * * The queue resource policy will be updated to allow this SNS topic to send * messages to the queue. * * TODO: change to QueueRef. * * @param name The subscription name * @param queue The target queue */ subscribeQueue(queue: sqs.QueueRef): Subscription; /** * Defines a subscription from this SNS Topic to a Lambda function. * * The Lambda's resource policy will be updated to allow this topic to * invoke the function. * * @param name A name for the subscription * @param lambdaFunction The Lambda function to invoke */ subscribeLambda(lambdaFunction: lambda.FunctionRef): Subscription; /** * Defines a subscription from this SNS topic to an email address. * * @param name A name for the subscription * @param emailAddress The email address to use. * @param jsonFormat True if the email content should be in JSON format (default is false). */ subscribeEmail(name: string, emailAddress: string, options?: EmailSubscriptionOptions): Subscription; /** * Defines a subscription from this SNS topic to an http:// or https:// URL. * * @param name A name for the subscription * @param url The URL to invoke */ subscribeUrl(name: string, url: string): Subscription; /** * Adds a statement to the IAM resource policy associated with this topic. * * If this topic was created in this stack (`new Topic`), a topic policy * will be automatically created upon the first call to `addToPolicy`. If * the topic is improted (`Topic.import`), then this is a no-op. */ addToResourcePolicy(statement: cdk.PolicyStatement): void; /** * Grant topic publishing permissions to the given identity */ grantPublish(identity?: iam.IIdentityResource): void; /** * Returns a RuleTarget that can be used to trigger this SNS topic as a * result from a CloudWatch event. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/resource-based-policies-cwe.html#sns-permissions */ asEventRuleTarget(_ruleArn: events.RuleArn, _ruleId: string): events.EventRuleTargetProps; readonly alarmActionArn: cdk.Arn; /** * Construct a Metric object for the current topic for the given metric */ metric(metricName: string, props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the size of messages published through this topic * * @default average over 5 minutes */ metricPublishSize(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of messages published through this topic * * @default sum over 5 minutes */ metricNumberOfMessagesPublished(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of messages that failed to publish through this topic * * @default sum over 5 minutes */ metricNumberOfMessagesFailed(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of messages that were successfully delivered through this topic * * @default sum over 5 minutes */ metricNumberOfMessagesDelivered(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Implements the IBucketNotificationDestination interface, allowing topics to be used * as bucket notification destinations. * * @param bucketArn The ARN of the bucket sending the notifications * @param bucketId A unique ID of the bucket */ asBucketNotificationDestination(bucketArn: cdk.Arn, bucketId: string): s3n.BucketNotificationDestinationProps; } /** * Reference to an external topic. */ export interface TopicRefProps { topicArn: TopicArn; topicName: TopicName; } /** * Options for email subscriptions. */ export interface EmailSubscriptionOptions { /** * Indicates if the full notification JSON should be sent to the email * address or just the message text. * * @default Message text (false) */ json?: boolean; }