Skip to content

Commit

Permalink
Merge pull request #2706 from pracucci/fix-sns-receiver-http-client
Browse files Browse the repository at this point in the history
Fix HTTP client options in SNS receiver
  • Loading branch information
roidelapluie authored Sep 14, 2021
2 parents c1b05a6 + 8006780 commit e35efbd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions notify/sns/sns.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err
tmpl = notify.TmplText(n.tmpl, data, &err)
)

client, err := createSNSClient(n, tmpl)
client, err := createSNSClient(n.client, n, tmpl)
if err != nil {
if e, ok := err.(awserr.RequestFailure); ok {
return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message()))
Expand Down Expand Up @@ -96,7 +96,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err
return false, nil
}

func createSNSClient(n *Notifier, tmpl func(string) string) (*sns.SNS, error) {
func createSNSClient(httpClient *http.Client, n *Notifier, tmpl func(string) string) (*sns.SNS, error) {
var creds *credentials.Credentials = nil
// If there are provided sigV4 credentials we want to use those to create a session.
if n.conf.Sigv4.AccessKey != "" && n.conf.Sigv4.SecretKey != "" {
Expand Down Expand Up @@ -133,7 +133,7 @@ func createSNSClient(n *Notifier, tmpl func(string) string) (*sns.SNS, error) {
creds = stscreds.NewCredentials(stsSess, n.conf.Sigv4.RoleARN)
}
// Use our generated session with credentials to create the SNS Client.
client := sns.New(sess, &aws.Config{Credentials: creds})
client := sns.New(sess, &aws.Config{Credentials: creds, HTTPClient: httpClient})
// We will always need a region to be set by either the local config or the environment.
if aws.StringValue(sess.Config.Region) == "" {
return nil, fmt.Errorf("region not configured in sns.sigv4.region or in default credentials chain")
Expand Down

0 comments on commit e35efbd

Please sign in to comment.