Skip to content

Commit

Permalink
fix: topic region must match client region
Browse files Browse the repository at this point in the history
  • Loading branch information
iamKunalGupta committed Mar 1, 2024
1 parent 33fa24d commit 639302e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions flow/shared/telemetry/sns_message_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func (s *SNSMessageSenderImpl) SendMessage(ctx context.Context, subject string,
}

func NewSNSMessageSenderWithNewClient(ctx context.Context, config *SNSMessageSenderConfig) (SNSMessageSender, error) {
client, err := newSnsClient(ctx)
// Topic Region must match client region
region := strings.Split(strings.TrimPrefix(config.Topic, "arn:aws:sns:"), ":")[0]
client, err := newSnsClient(ctx, &region)
if err != nil {
return nil, err
}
Expand All @@ -75,8 +77,12 @@ func NewSNSMessageSender(client *sns.Client, config *SNSMessageSenderConfig) SNS
}
}

func newSnsClient(ctx context.Context) (*sns.Client, error) {
sdkConfig, err := config.LoadDefaultConfig(ctx)
func newSnsClient(ctx context.Context, region *string) (*sns.Client, error) {
sdkConfig, err := config.LoadDefaultConfig(ctx, func(options *config.LoadOptions) error {
if region != nil {
options.Region = *region
}
})
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 639302e

Please sign in to comment.