mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-27 08:32:15 +00:00
Make API URL optional, clear up credential logic
Signed-off-by: Tyler Reid <tyler.reid@grafana.com>
This commit is contained in:
parent
4ebcaf9c23
commit
8911051770
@ -606,7 +606,7 @@ type SNSConfig struct {
|
||||
|
||||
HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`
|
||||
|
||||
APIUrl string `yaml:"api_url" json:"api_url"`
|
||||
APIUrl string `yaml:"api_url,omitempty" json:"api_url,omitempty"`
|
||||
Sigv4 SigV4Config `yaml:"sigv4" json:"sigv4"`
|
||||
TopicARN string `yaml:"topic_arn,omitempty" json:"topic_arn,omitempty"`
|
||||
PhoneNumber string `yaml:"phone_number,omitempty" json:"phone_number,omitempty"`
|
||||
|
@ -698,7 +698,8 @@ value: <tmpl_string>
|
||||
# Whether or not to notify about resolved alerts.
|
||||
[ send_resolved: <boolean> | default = false ]
|
||||
|
||||
# The SNS API URL i.e. https://sns.us-east-2.amazonaws.com
|
||||
# The SNS API URL i.e. https://sns.us-east-2.amazonaws.com.
|
||||
# If not specified, the SNS API URL from the SNS SDK will be used.
|
||||
[api_url: <tmpl_string>]
|
||||
|
||||
# Configures AWS's Signature Verification 4 signing process to sign requests.
|
||||
|
@ -79,16 +79,11 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err
|
||||
sess, err := session.NewSessionWithOptions(session.Options{
|
||||
Config: aws.Config{
|
||||
Region: aws.String(n.conf.Sigv4.Region),
|
||||
Credentials: creds,
|
||||
Endpoint: aws.String(tmpl(n.conf.APIUrl)),
|
||||
},
|
||||
Profile: n.conf.Sigv4.Profile,
|
||||
})
|
||||
|
||||
if _, err := sess.Config.Credentials.Get(); err != nil {
|
||||
return false, fmt.Errorf("could not get SigV4 credentials: %w", err)
|
||||
}
|
||||
|
||||
if n.conf.Sigv4.RoleARN != "" {
|
||||
sess.Config.Credentials = stscreds.NewCredentials(sess, n.conf.Sigv4.RoleARN)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user