- Newest
- Most votes
- Most comments
Hello @jona
Amazon SNS doesn't directly support setting a Time-to-Live (TTL) for SMS messages. TTL is a feature for message queues, not for immediate delivery services like SMS via SNS. SMS messages are typically delivered immediately or fail quickly.
To configure Time-to-Live (TTL) for SMS messages sent via the Amazon Simple Notification Service (SNS) Publish API, follow these steps:
Step 1: Understand TTL in SNS TTL (Time-to-Live) is a parameter that defines how long a message should be retained if it cannot be delivered immediately. For SMS messages, this is particularly useful to ensure messages are not delivered after a certain period if the recipient is unavailable.
Step 2: Access the AWS Management Console Log in to your AWS Management Console. Navigate to the SNS service.
Step 3: Create or Select an SNS Topic If you haven't already, create an SNS topic that will be used to send SMS messages. Alternatively, select an existing topic.
Step 4: Configure Message Attributes for TTL When publishing a message to the SNS topic, you can specify message attributes. Use the AWS.SNS SDK or AWS CLI to set the AWS.SNS.SMS.MaxPrice attribute, which indirectly influences TTL by controlling cost and delivery speed.
Step 5: Publish a Message with TTL Use the AWS SDK for your preferred programming language or AWS CLI to publish a message. Include the MessageAttributes parameter to set TTL. Note that SNS does not directly support TTL for SMS, but you can manage retries and delivery settings through attributes. Example using AWS CLI:
aws sns publish \ --phone-number "+1234567890" \ --message "Your message here" \ --message-attributes '{"AWS.SNS.SMS.MaxPrice":{"DataType":"String","StringValue":"0.50"}}'
Step 6: Monitor Message Delivery Use CloudWatch metrics to monitor the delivery status of your SMS messages. Adjust your TTL strategy based on delivery success and failure rates.
Final Answer AWS SNS does not directly support TTL for SMS messages, but you can manage delivery settings through message attributes like MaxPrice. Use the AWS SDK or CLI to set these attributes when publishing messages. Monitor delivery with CloudWatch to optimize your SMS strategy.
If the Answer is helpful, please click Accept Answer
& UPVOTE
, this can be beneficial to other community members.
Relevant content
- asked 4 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
To configure Time-to-Live (TTL) for SMS messages sent via the Amazon SNS Publish API, you can follow these steps:
Specify the TTL value in the message attributes when publishing the SMS message:
--phone-number "+12345678901"
--message "This is a test SMS message"
--message-attributes '{"AWS_SNS_SMS_TTL":{"DataType":"Number","StringValue":"600"}}'
Here are some article for the reference. https://docs.aws.amazon.com/sns/latest/dg/example_sns_PublishTextSMS_section.html https://docs.aws.amazon.com/sns/latest/dg/sns-ttl.html