AWS SDK for Ruby
Developer Guide

Creating a Subscription in an Amazon SNS Topic

The following example creates a subscription for the topic with the ARN arn:aws:sns:us-west-2:123456789:MyGroovyTopic for a user who has the email address MyGroovyUser@MyGroovy.com in the us-west-2 region, and displays the resulting ARN. Initially the ARN value is pending confirmation. When the user confirms their email address, this value becomes a true ARN.

require 'aws-sdk-sns' # v2: require 'aws-sdk' sns = Aws::SNS::Resource.new(region: 'us-west-2') topic = sns.topic('arn:aws:sns:us-west-2:123456789:MyGroovyTopic') sub = topic.subscribe({ protocol: 'email', endpoint: 'MyGroovyUser@MyGroovy.com' }) puts sub.arn