Skip to content

Commit

Permalink
[7.15](backport #28725) Change proxy_url from url.URL to string (#28793)
Browse files Browse the repository at this point in the history
* Change proxy_url from url.URL to string (#28725)

(cherry picked from commit f025c96)

# Conflicts:
#	x-pack/libbeat/common/aws/credentials.go

* Update credentials.go

* Update credentials.go

Co-authored-by: kaiyan-sheng <[email protected]>
  • Loading branch information
mergify[bot] and kaiyan-sheng authored Nov 4, 2021
1 parent c5460fe commit 80e5b22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix handling of float data types within processors. {issue}28279[28279] {pull}28280[28280]
- Allow `clone3` syscall in seccomp filters. {pull}28117[28117]
- Remove unnecessary escaping step in dashboard loading, so they can be displayed in Kibana. {pull}28395[28395]
- Fix AWS proxy_url config from url to string type. {pull}28725[28725]
- Fix `fingerprint` processor to give it access to the `@timestamp` field. {issue}28683[28683]

*Auditbeat*
Expand Down
29 changes: 17 additions & 12 deletions x-pack/libbeat/common/aws/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package aws

import (
"net/http"
"net/url"

awssdk "github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/defaults"
Expand All @@ -16,29 +15,35 @@ import (
"github.com/pkg/errors"

"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
"github.com/elastic/beats/v7/libbeat/common/transport/httpcommon"
"github.com/elastic/beats/v7/libbeat/logp"
)

// ConfigAWS is a structure defined for AWS credentials
type ConfigAWS struct {
AccessKeyID string `config:"access_key_id"`
SecretAccessKey string `config:"secret_access_key"`
SessionToken string `config:"session_token"`
ProfileName string `config:"credential_profile_name"`
SharedCredentialFile string `config:"shared_credential_file"`
Endpoint string `config:"endpoint"`
RoleArn string `config:"role_arn"`
AWSPartition string `config:"aws_partition"` // Deprecated.
ProxyUrl *url.URL `config:"proxy_url"`
AccessKeyID string `config:"access_key_id"`
SecretAccessKey string `config:"secret_access_key"`
SessionToken string `config:"session_token"`
ProfileName string `config:"credential_profile_name"`
SharedCredentialFile string `config:"shared_credential_file"`
Endpoint string `config:"endpoint"`
RoleArn string `config:"role_arn"`
AWSPartition string `config:"aws_partition"` // Deprecated.
ProxyUrl string `config:"proxy_url"`
}

// InitializeAWSConfig function creates the awssdk.Config object from the provided config
func InitializeAWSConfig(config ConfigAWS) (awssdk.Config, error) {
AWSConfig, _ := GetAWSCredentials(config)
if config.ProxyUrl != nil {
if config.ProxyUrl != "" {
proxyUrl, err := httpcommon.NewProxyURIFromString(config.ProxyUrl)
if err != nil {
return AWSConfig, err
}

httpClient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(config.ProxyUrl),
Proxy: http.ProxyURL(proxyUrl.URI()),
},
}
AWSConfig.HTTPClient = httpClient
Expand Down

0 comments on commit 80e5b22

Please sign in to comment.