Skip to content

Commit

Permalink
Source SMS from only us-east-1 region
Browse files Browse the repository at this point in the history
  • Loading branch information
docwho2 committed Dec 2, 2023
1 parent 553269e commit 08ae2e9
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cloud.cleo.squareup.functions;

import java.util.function.Function;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sns.SnsClient;

/**
Expand Down Expand Up @@ -31,7 +32,12 @@ protected Function getExecutor() {
return mapper.createObjectNode().put("status","FAILED").put("message", "Caller is not calling from a mobile device");
}

final var result = SnsClient.create().publish(b -> b.phoneNumber(callingNumber).message(DRIVING_DIRECTIONS_URL) );
final var result = SnsClient.builder()
// Force SMS sending to east because that's where all the 10DLC and campaign crap setup is done
// Otherwise have to pay for registrations and numbers in 2 regions, HUGE HASSLE (and more monthly cost)
// Also then all texts are sourced from the same phone number for consistancy
.region(Region.US_EAST_1).build()
.publish(b -> b.phoneNumber(callingNumber).message(DRIVING_DIRECTIONS_URL) );
log.info("SMS Directions sent to " + callingNumber + " with SNS id of " + result.messageId());
return mapper.createObjectNode().put("status","SUCCESS").put("message", "The directions have been sent");
} catch (Exception e) {
Expand Down

0 comments on commit 08ae2e9

Please sign in to comment.