2 Answers
- Newest
- Most votes
- Most comments
0
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 ;)
0
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.")
Relevant content
- asked 10 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 2 years ago