pub struct TopicBuilder<T: TopicBuilderState> { /* private fields */ }Expand description
Builder for SNS topics.
Supports both standard and FIFO topics with Lambda subscriptions. FIFO topics have additional configuration for deduplication and throughput.
§Example
use rusty_cdk_core::stack::StackBuilder;
use rusty_cdk_core::sns::{TopicBuilder, SubscriptionType};
let mut stack_builder = StackBuilder::new();
// Create a simple topic without subscriptions
let simple_topic = TopicBuilder::new("simple-topic")
.build(&mut stack_builder);
let function = unimplemented!("create a function");
// Create a topic with a Lambda subscription
let topic = TopicBuilder::new("my-topic")
.add_subscription(SubscriptionType::Lambda(&function))
.build(&mut stack_builder);
Implementations§
Source§impl TopicBuilder<StartState>
impl TopicBuilder<StartState>
Sourcepub fn add_subscription(
self,
subscription: SubscriptionType<'_>,
) -> TopicBuilder<StandardStateWithSubscriptions>
pub fn add_subscription( self, subscription: SubscriptionType<'_>, ) -> TopicBuilder<StandardStateWithSubscriptions>
Adds a subscription to the topic.
For Lambda subscriptions, automatically creates the necessary permission.
pub fn build(self, stack_builder: &mut StackBuilder) -> TopicRef
Source§impl TopicBuilder<StandardStateWithSubscriptions>
impl TopicBuilder<StandardStateWithSubscriptions>
pub fn add_subscription( self, subscription: SubscriptionType<'_>, ) -> TopicBuilder<StandardStateWithSubscriptions>
pub fn build(self, stack_builder: &mut StackBuilder) -> TopicRef
Source§impl<T: TopicBuilderState> TopicBuilder<T>
impl<T: TopicBuilderState> TopicBuilder<T>
pub fn topic_name( self, topic_name: StringWithOnlyAlphaNumericsUnderscoresAndHyphens, ) -> TopicBuilder<T>
pub fn fifo(self) -> TopicBuilder<FifoState>
Sourcepub fn topic_policy(self, doc: PolicyDocument) -> TopicBuilder<T>
pub fn topic_policy(self, doc: PolicyDocument) -> TopicBuilder<T>
Adds an SNS Topic Policy for this topic.
The code will automatically set the resources section of the PolicyDocument to the ARN of this queue, so there’s no need to pass that in.
Source§impl TopicBuilder<FifoState>
impl TopicBuilder<FifoState>
pub fn fifo_throughput_scope( self, scope: FifoThroughputScope, ) -> TopicBuilder<FifoState>
pub fn content_based_deduplication( self, content_based_deduplication: bool, ) -> TopicBuilder<FifoState>
pub fn add_subscription( self, subscription: SubscriptionType<'_>, ) -> TopicBuilder<FifoStateWithSubscriptions>
Sourcepub fn build(self, stack_builder: &mut StackBuilder) -> TopicRef
pub fn build(self, stack_builder: &mut StackBuilder) -> TopicRef
Builds the FIFO topic and adds it to the stack.
Automatically appends the required “.fifo” suffix to the topic name if not already present.
Source§impl TopicBuilder<FifoStateWithSubscriptions>
impl TopicBuilder<FifoStateWithSubscriptions>
pub fn fifo_throughput_scope( self, scope: FifoThroughputScope, ) -> TopicBuilder<FifoStateWithSubscriptions>
pub fn content_based_deduplication( self, content_based_deduplication: bool, ) -> TopicBuilder<FifoStateWithSubscriptions>
pub fn add_subscription( self, subscription: SubscriptionType<'_>, ) -> TopicBuilder<FifoStateWithSubscriptions>
Sourcepub fn build(self, stack_builder: &mut StackBuilder) -> TopicRef
pub fn build(self, stack_builder: &mut StackBuilder) -> TopicRef
Builds the FIFO topic with subscriptions and adds it to the stack.
Automatically appends the required “.fifo” suffix to the topic name if not already present. Creates Lambda permissions for all subscriptions.