@@ -28,6 +28,7 @@ import (
2828 "github.com/pkg/errors"
2929 commoncfg "github.com/prometheus/common/config"
3030 "github.com/prometheus/common/model"
31+ "github.com/prometheus/common/sigv4"
3132 "gopkg.in/yaml.v2"
3233
3334 "github.com/prometheus/alertmanager/pkg/labels"
@@ -454,6 +455,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
454455 if sns .HTTPConfig == nil {
455456 sns .HTTPConfig = c .Global .HTTPConfig
456457 }
458+ sns .Sigv4 = mergeSigV4Configs (sns .Sigv4 , c .Global .Sigv4 )
457459 }
458460 names [rcv .Name ] = struct {}{}
459461 }
@@ -522,6 +524,49 @@ func checkTimeInterval(r *Route, timeIntervals map[string]struct{}) error {
522524 return nil
523525}
524526
527+ func mergeSigV4Configs (snsSigV4Config sigv4.SigV4Config , globalSigV4Config sigv4.SigV4Config ) sigv4.SigV4Config {
528+ var (
529+ accessKey string
530+ secretKey commoncfg.Secret
531+ region string
532+ profile string
533+ roleARN string
534+ )
535+
536+ if snsSigV4Config .AccessKey == "" {
537+ accessKey = globalSigV4Config .AccessKey
538+ } else {
539+ accessKey = snsSigV4Config .AccessKey
540+ }
541+ if snsSigV4Config .SecretKey == "" {
542+ secretKey = globalSigV4Config .SecretKey
543+ } else {
544+ secretKey = snsSigV4Config .SecretKey
545+ }
546+ if snsSigV4Config .Region == "" {
547+ region = globalSigV4Config .Region
548+ } else {
549+ region = snsSigV4Config .Region
550+ }
551+ if snsSigV4Config .Profile == "" {
552+ profile = globalSigV4Config .Profile
553+ } else {
554+ profile = snsSigV4Config .Profile
555+ }
556+ if snsSigV4Config .RoleARN == "" {
557+ roleARN = globalSigV4Config .RoleARN
558+ } else {
559+ roleARN = snsSigV4Config .RoleARN
560+ }
561+ return sigv4.SigV4Config {
562+ Region : region ,
563+ AccessKey : accessKey ,
564+ SecretKey : secretKey ,
565+ Profile : profile ,
566+ RoleARN : roleARN ,
567+ }
568+ }
569+
525570// DefaultGlobalConfig returns GlobalConfig with default values.
526571func DefaultGlobalConfig () GlobalConfig {
527572 var defaultHTTPConfig = commoncfg .DefaultHTTPClientConfig
@@ -636,24 +681,25 @@ type GlobalConfig struct {
636681
637682 HTTPConfig * commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`
638683
639- SMTPFrom string `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"`
640- SMTPHello string `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"`
641- SMTPSmarthost HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"`
642- SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"`
643- SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"`
644- SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"`
645- SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"`
646- SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"`
647- SlackAPIURL * SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"`
648- SlackAPIURLFile string `yaml:"slack_api_url_file,omitempty" json:"slack_api_url_file,omitempty"`
649- PagerdutyURL * URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"`
650- OpsGenieAPIURL * URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"`
651- OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"`
652- WeChatAPIURL * URL `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"`
653- WeChatAPISecret Secret `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"`
654- WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"`
655- VictorOpsAPIURL * URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"`
656- VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"`
684+ SMTPFrom string `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"`
685+ SMTPHello string `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"`
686+ SMTPSmarthost HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"`
687+ SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"`
688+ SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"`
689+ SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"`
690+ SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"`
691+ SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"`
692+ SlackAPIURL * SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"`
693+ SlackAPIURLFile string `yaml:"slack_api_url_file,omitempty" json:"slack_api_url_file,omitempty"`
694+ PagerdutyURL * URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"`
695+ OpsGenieAPIURL * URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"`
696+ OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"`
697+ WeChatAPIURL * URL `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"`
698+ WeChatAPISecret Secret `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"`
699+ WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"`
700+ VictorOpsAPIURL * URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"`
701+ VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"`
702+ Sigv4 sigv4.SigV4Config `yaml:"sigv4,omitempty" json:"sigv4,omitempty"`
657703}
658704
659705// UnmarshalYAML implements the yaml.Unmarshaler interface for GlobalConfig.
0 commit comments