- Newest
- Most votes
- Most comments
Hi,
you can look into SNS subscription filter policies: https://docs.aws.amazon.com/sns/latest/dg/sns-subscription-filter-policies.html.
You could have a filter policy that prevents messages to be forwarded if the a country field is from one of those ones. https://docs.aws.amazon.com/sns/latest/dg/example-filter-policies.html
Hope it helps ;)
as i know
https://docs.aws.amazon.com/sns/latest/dg/example-filter-policies.html
filter policies can block messages but these filters cannot be used to block messages according to country
but you can implement country-based restrictions in your application code or by using an external service.
example
import phonenumbers
def is_restricted_country(phone_number, restricted_countries):
parsed_number = phonenumbers.parse(phone_number)
country_code = phonenumbers.region_code_for_country_code(parsed_number.country_code)
return country_code in restricted_countries
import boto3
def send_sms(phone_number, message):
if not is_restricted_country(phone_number, restricted_countries):
sns_client = boto3.client('sns')
response = sns_client.publish(
PhoneNumber=phone_number,
Message=message
)
print(f"SMS sent to {phone_number}. Response: {response}")
else:
print(f"SMS not sent. {phone_number} belongs to a restricted country.")
This new feature should help here: https://aws.amazon.com/about-aws/whats-new/2024/05/amazon-pinpoint-country-control-sms-delivery/
Although announced for Pinpoint, it affects SNS as well (as per documentation: https://docs.aws.amazon.com/sms-voice/latest/userguide/protect-configuration.html).
Relevant content
- asked 2 years ago
- asked 5 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 10 months ago