Module: AWSCDK::SNS::ITopic

Includes:
CodeStarNotifications::INotificationRuleTarget, IResource, Interfaces::AWSSNS::ITopicRef
Included in:
TopicBase
Defined in:
sns/i_topic.rb

Overview

Represents an SNS topic.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jsii_overridable_methodsObject



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'sns/i_topic.rb', line 287

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :topic_ref => { kind: :property, name: "topicRef", is_optional: false },
    :content_based_deduplication => { kind: :property, name: "contentBasedDeduplication", is_optional: false },
    :fifo => { kind: :property, name: "fifo", is_optional: false },
    :topic_arn => { kind: :property, name: "topicArn", is_optional: false },
    :topic_name => { kind: :property, name: "topicName", is_optional: false },
    :master_key => { kind: :property, name: "masterKey", is_optional: true },
    :with => { kind: :method, name: "with", is_optional: false },
    :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false },
    :bind_as_notification_rule_target => { kind: :method, name: "bindAsNotificationRuleTarget", is_optional: false },
    :add_subscription => { kind: :method, name: "addSubscription", is_optional: false },
    :add_to_resource_policy => { kind: :method, name: "addToResourcePolicy", is_optional: false },
    :grant_publish => { kind: :method, name: "grantPublish", is_optional: false },
    :grant_subscribe => { kind: :method, name: "grantSubscribe", is_optional: false },
    :metric => { kind: :method, name: "metric", is_optional: false },
    :metric_number_of_messages_published => { kind: :method, name: "metricNumberOfMessagesPublished", is_optional: false },
    :metric_number_of_notifications_delivered => { kind: :method, name: "metricNumberOfNotificationsDelivered", is_optional: false },
    :metric_number_of_notifications_failed => { kind: :method, name: "metricNumberOfNotificationsFailed", is_optional: false },
    :metric_number_of_notifications_filtered_out => { kind: :method, name: "metricNumberOfNotificationsFilteredOut", is_optional: false },
    :metric_number_of_notifications_filtered_out_invalid_attributes => { kind: :method, name: "metricNumberOfNotificationsFilteredOutInvalidAttributes", is_optional: false },
    :metric_number_of_notifications_filtered_out_no_message_attributes => { kind: :method, name: "metricNumberOfNotificationsFilteredOutNoMessageAttributes", is_optional: false },
    :metric_publish_size => { kind: :method, name: "metricPublishSize", is_optional: false },
    :metric_sms_month_to_date_spent_usd => { kind: :method, name: "metricSMSMonthToDateSpentUSD", is_optional: false },
    :metric_sms_success_rate => { kind: :method, name: "metricSMSSuccessRate", is_optional: false },
  }
end

Instance Method Details

#add_subscription(subscription) ⇒ AWSCDK::SNS::Subscription

Subscribe some endpoint to this topic.

Parameters:

Returns:



131
132
133
134
# File 'sns/i_topic.rb', line 131

def add_subscription(subscription)
  Jsii::Type.check_type(subscription, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc25zLklUb3BpY1N1YnNjcmlwdGlvbiJ9")), "subscription")
  jsii_call_method("addSubscription", [subscription])
end

#add_to_resource_policy(statement) ⇒ AWSCDK::IAM::AddToResourcePolicyResult

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 add_to_resource_policy. If the topic is imported (Topic.import), then this is a no-op.



144
145
146
147
# File 'sns/i_topic.rb', line 144

def add_to_resource_policy(statement)
  Jsii::Type.check_type(statement, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeVN0YXRlbWVudCJ9")), "statement")
  jsii_call_method("addToResourcePolicy", [statement])
end

#apply_removal_policy(policy) ⇒ void

This method returns an undefined value.

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:



113
114
115
116
# File 'sns/i_topic.rb', line 113

def apply_removal_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy")
  jsii_call_method("applyRemovalPolicy", [policy])
end

#bind_as_notification_rule_target(scope) ⇒ AWSCDK::CodeStarNotifications::NotificationRuleTargetConfig

Returns a target configuration for notification rule.

Parameters:

  • scope (Constructs::Construct)

Returns:



122
123
124
125
# File 'sns/i_topic.rb', line 122

def bind_as_notification_rule_target(scope)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  jsii_call_method("bindAsNotificationRuleTarget", [scope])
end

#content_based_deduplicationBoolean

Enables content-based deduplication for FIFO topics.

Returns:

  • (Boolean)


49
50
51
# File 'sns/i_topic.rb', line 49

def content_based_deduplication()
  jsii_get_property("contentBasedDeduplication")
end

#envAWSCDK::Interfaces::ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.



28
29
30
# File 'sns/i_topic.rb', line 28

def env()
  jsii_get_property("env")
end

#fifoBoolean

Whether this topic is an Amazon SNS FIFO queue.

If false, this is a standard topic.

Returns:

  • (Boolean)


58
59
60
# File 'sns/i_topic.rb', line 58

def fifo()
  jsii_get_property("fifo")
end

#grant_publish(identity) ⇒ AWSCDK::IAM::Grant

Grant topic publishing permissions to the given identity.

Parameters:

Returns:



153
154
155
156
# File 'sns/i_topic.rb', line 153

def grant_publish(identity)
  Jsii::Type.check_type(identity, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "identity")
  jsii_call_method("grantPublish", [identity])
end

#grant_subscribe(identity) ⇒ AWSCDK::IAM::Grant

Grant topic subscribing permissions to the given identity.

Parameters:

Returns:



162
163
164
165
# File 'sns/i_topic.rb', line 162

def grant_subscribe(identity)
  Jsii::Type.check_type(identity, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "identity")
  jsii_call_method("grantSubscribe", [identity])
end

#master_keyAWSCDK::KMS::IKey?

Note:

Default: None

A KMS Key, either managed by this CDK app, or imported.

This property applies only to server-side encryption.



83
84
85
# File 'sns/i_topic.rb', line 83

def master_key()
  jsii_get_property("masterKey")
end

#metric(metric_name, props = nil) ⇒ AWSCDK::CloudWatch::Metric

Return the given named metric for this Topic.

Parameters:

Returns:



172
173
174
175
176
177
# File 'sns/i_topic.rb', line 172

def metric(metric_name, props = nil)
  Jsii::Type.check_type(metric_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricName")
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric", [metric_name, props])
end

#metric_number_of_messages_published(props = nil) ⇒ AWSCDK::CloudWatch::Metric

The number of messages published to your Amazon SNS topics.

Sum over 5 minutes

Parameters:

Returns:



185
186
187
188
189
# File 'sns/i_topic.rb', line 185

def metric_number_of_messages_published(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricNumberOfMessagesPublished", [props])
end

#metric_number_of_notifications_delivered(props = nil) ⇒ AWSCDK::CloudWatch::Metric

The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints.

Sum over 5 minutes

Parameters:

Returns:



197
198
199
200
201
# File 'sns/i_topic.rb', line 197

def metric_number_of_notifications_delivered(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricNumberOfNotificationsDelivered", [props])
end

#metric_number_of_notifications_failed(props = nil) ⇒ AWSCDK::CloudWatch::Metric

The number of messages that Amazon SNS failed to deliver.

Sum over 5 minutes

Parameters:

Returns:



209
210
211
212
213
# File 'sns/i_topic.rb', line 209

def metric_number_of_notifications_failed(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricNumberOfNotificationsFailed", [props])
end

#metric_number_of_notifications_filtered_out(props = nil) ⇒ AWSCDK::CloudWatch::Metric

The number of messages that were rejected by subscription filter policies.

Sum over 5 minutes

Parameters:

Returns:



221
222
223
224
225
# File 'sns/i_topic.rb', line 221

def metric_number_of_notifications_filtered_out(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricNumberOfNotificationsFilteredOut", [props])
end

#metric_number_of_notifications_filtered_out_invalid_attributes(props = nil) ⇒ AWSCDK::CloudWatch::Metric

The number of messages that were rejected by subscription filter policies because the messages' attributes are invalid.

Sum over 5 minutes

Parameters:

Returns:



233
234
235
236
237
# File 'sns/i_topic.rb', line 233

def metric_number_of_notifications_filtered_out_invalid_attributes(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricNumberOfNotificationsFilteredOutInvalidAttributes", [props])
end

#metric_number_of_notifications_filtered_out_no_message_attributes(props = nil) ⇒ AWSCDK::CloudWatch::Metric

The number of messages that were rejected by subscription filter policies because the messages have no attributes.

Sum over 5 minutes

Parameters:

Returns:



245
246
247
248
249
# File 'sns/i_topic.rb', line 245

def metric_number_of_notifications_filtered_out_no_message_attributes(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricNumberOfNotificationsFilteredOutNoMessageAttributes", [props])
end

#metric_publish_size(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Metric for the size of messages published through this topic.

Average over 5 minutes

Parameters:

Returns:



257
258
259
260
261
# File 'sns/i_topic.rb', line 257

def metric_publish_size(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricPublishSize", [props])
end

#metric_sms_month_to_date_spent_usd(props = nil) ⇒ AWSCDK::CloudWatch::Metric

The charges you have accrued since the start of the current calendar month for sending SMS messages.

Maximum over 5 minutes

Parameters:

Returns:



269
270
271
272
273
# File 'sns/i_topic.rb', line 269

def metric_sms_month_to_date_spent_usd(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricSMSMonthToDateSpentUSD", [props])
end

#metric_sms_success_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

The rate of successful SMS message deliveries.

Sum over 5 minutes

Parameters:

Returns:



281
282
283
284
285
# File 'sns/i_topic.rb', line 281

def metric_sms_success_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricSMSSuccessRate", [props])
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


13
14
15
# File 'sns/i_topic.rb', line 13

def node()
  jsii_get_property("node")
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



35
36
37
# File 'sns/i_topic.rb', line 35

def stack()
  jsii_get_property("stack")
end

#topic_arnString

The ARN of the topic.

Returns:

  • (String)


65
66
67
# File 'sns/i_topic.rb', line 65

def topic_arn()
  jsii_get_property("topicArn")
end

#topic_nameString

The name of the topic.

Returns:

  • (String)


72
73
74
# File 'sns/i_topic.rb', line 72

def topic_name()
  jsii_get_property("topicName")
end

#topic_refAWSCDK::Interfaces::AWSSNS::TopicReference

A reference to a Topic resource.



42
43
44
# File 'sns/i_topic.rb', line 42

def topic_ref()
  jsii_get_property("topicRef")
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



94
95
96
97
98
99
# File 'sns/i_topic.rb', line 94

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end