Skip to content

Commit

Permalink
Remove deprecated AWS config options (#28120)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiyan-sheng authored Oct 4, 2021
1 parent 67f2e2b commit b33fc41
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 60 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Skip add_kubernetes_metadata processor when kubernetes metadata are already present {pull}27689[27689]
- Remove deprecated/undocumented IncludeCreatorMetadata setting from kubernetes metadata config options {pull}28006[28006]
- Remove deprecated fields from kubernetes module {pull}28046[28046]
- Remove deprecated config option aws_partition. {pull}28120[28120]

*Auditbeat*

Expand Down Expand Up @@ -112,6 +113,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Errors should be thrown as errors. Metricsets inside Metricbeat will now throw errors as the `error` log level. {pull}27804[27804]
- Remove deprecated fields in Docker module. {issue}11835[11835] {pull}27933[27933]
- Remove deprecated fields in Kafka module. {pull}27938[27938]
- Remove deprecated config option default_region from aws module. {pull}28120[28120]

*Packetbeat*

Expand Down
10 changes: 0 additions & 10 deletions x-pack/libbeat/common/aws/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/aws/aws-sdk-go-v2/service/sts"
"github.com/pkg/errors"

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

Expand All @@ -28,7 +27,6 @@ type ConfigAWS struct {
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"`
}

Expand Down Expand Up @@ -148,11 +146,3 @@ func EnrichAWSConfigWithEndpoint(endpoint string, serviceName string, regionName
}
return awsConfig
}

// Validate checks for deprecated config option
func (c ConfigAWS) Validate() error {
if c.AWSPartition != "" {
cfgwarn.Deprecate("8.0.0", "aws_partition is deprecated. Please use endpoint instead.")
}
return nil
}
4 changes: 1 addition & 3 deletions x-pack/libbeat/docs/aws-credentials-config.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ After these steps are done, IAM role ARN can be used for authentication in Metri
Temporary security credentials has a limited lifetime and consists of an
access key ID, a secret access key, and a security token which typically returned
from `GetSessionToken`. MFA-enabled IAM users would need to submit an MFA code
while calling `GetSessionToken`. `default_region` identifies the AWS Region
whose servers you want to send your first API request to by default. This is
typically the Region closest to you, but it can be any Region. Please see
while calling `GetSessionToken`. Please see
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html[Temporary Security Credentials]
for more details.
`sts get-session-token` AWS CLI can be used to generate temporary credentials. For example. with MFA-enabled:
Expand Down
14 changes: 0 additions & 14 deletions x-pack/metricbeat/module/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,6 @@ func NewMetricSet(base mb.BaseMetricSet) (*MetricSet, error) {
base.Logger().Debug("Metricset level config for tags filter: ", metricSet.TagsFilter)
base.Logger().Warn("extra charges on AWS API requests will be generated by this metricset")

// Get IAM account name, set region by aws_partition, default is aws global partition
// refer https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
if config.AWSConfig.AWSPartition != "" && config.AWSConfig.Endpoint != "" {
base.Logger().Warn("aws_partition is deprecated. Please use endpoint and regions instead.")
}
switch config.AWSConfig.AWSPartition {
case "aws-cn":
awsConfig.Region = "cn-north-1"
case "aws-us-gov":
awsConfig.Region = "us-gov-east-1"
default:
awsConfig.Region = "us-east-1"
}

// If regions in config is not empty, then overwrite the awsConfig.Region
if len(config.Regions) > 0 {
awsConfig.Region = config.Regions[0]
Expand Down
38 changes: 8 additions & 30 deletions x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/pkg/errors"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/metricbeat/mb"
awscommon "github.com/elastic/beats/v7/x-pack/libbeat/common/aws"
Expand Down Expand Up @@ -65,25 +64,11 @@ type Dimension struct {

// Config holds a configuration specific for cloudwatch metricset.
type Config struct {
Namespace string `config:"namespace" validate:"nonzero,required"`
MetricName []string `config:"name"`
Dimensions []Dimension `config:"dimensions"`
ResourceTypeFilter string `config:"tags.resource_type_filter"` // Deprecated.
ResourceType string `config:"resource_type"`
Statistic []string `config:"statistic"`
Tags []aws.Tag `config:"tags"` // Deprecated.
}

// Validate checks for deprecated config options
func (c Config) Validate() error {
if c.Tags != nil {
cfgwarn.Deprecate("8.0.0", "tags is deprecated. Use tags_filter instead")
}

if c.ResourceTypeFilter != "" {
cfgwarn.Deprecate("8.0.0", "tags.resource_type_filter is deprecated. Use resource_type instead")
}
return nil
Namespace string `config:"namespace" validate:"nonzero,required"`
MetricName []string `config:"name"`
Dimensions []Dimension `config:"dimensions"`
ResourceType string `config:"resource_type"`
Statistic []string `config:"statistic"`
}

type metricsWithStatistics struct {
Expand Down Expand Up @@ -318,13 +303,6 @@ func (m *MetricSet) readCloudwatchConfig() (listMetricWithDetail, map[string][]n
resourceTypesWithTags := map[string][]aws.Tag{}

for _, config := range m.CloudwatchConfigs {
// If tags_filter on metricset level is given, overwrite tags in
// cloudwatch metrics with tags_filter.
tagsFilter := config.Tags
if m.MetricSet.TagsFilter != nil {
tagsFilter = m.MetricSet.TagsFilter
}

// If there is no statistic method specified, then use the default.
if config.Statistic == nil {
config.Statistic = defaultStatistics
Expand Down Expand Up @@ -358,17 +336,17 @@ func (m *MetricSet) readCloudwatchConfig() (listMetricWithDetail, map[string][]n

if config.ResourceType != "" {
if _, ok := resourceTypesWithTags[config.ResourceType]; ok {
resourceTypesWithTags[config.ResourceType] = tagsFilter
resourceTypesWithTags[config.ResourceType] = m.MetricSet.TagsFilter
} else {
resourceTypesWithTags[config.ResourceType] = append(resourceTypesWithTags[config.ResourceType], tagsFilter...)
resourceTypesWithTags[config.ResourceType] = append(resourceTypesWithTags[config.ResourceType], m.MetricSet.TagsFilter...)
}
}
continue
}

configPerNamespace := namespaceDetail{
names: config.MetricName,
tags: tagsFilter,
tags: m.MetricSet.TagsFilter,
statistics: config.Statistic,
resourceTypeFilter: config.ResourceType,
dimensions: cloudwatchDimensions,
Expand Down
1 change: 0 additions & 1 deletion x-pack/metricbeat/module/aws/elb/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ image::./images/metricbeat-aws-elb-overview.png[]
access_key_id: '${AWS_ACCESS_KEY_ID:""}'
secret_access_key: '${AWS_SECRET_ACCESS_KEY:""}'
session_token: '${AWS_SESSION_TOKEN:""}'
default_region: '${AWS_REGION:us-west-1}'
# This module uses the aws cloudwatch metricset, all
# the options for this metricset are also available here.
----
Expand Down
1 change: 0 additions & 1 deletion x-pack/metricbeat/module/aws/mtest/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func GetConfigForTest(t *testing.T, metricSetName string, period string) map[str
"metricsets": []string{metricSetName},
"access_key_id": accessKeyID,
"secret_access_key": secretAccessKey,
"default_region": defaultRegion,
"latency": "5m",
// You can specify which region to run test on by using regions variable
// "regions": []string{"us-east-1"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
access_key_id: '${AWS_ACCESS_KEY_ID:""}'
secret_access_key: '${AWS_SECRET_ACCESS_KEY:""}'
session_token: '${AWS_SESSION_TOKEN:""}'
default_region: '${AWS_REGION:us-west-1}'
metrics:
- namespace: AWS/EC2
resource_type_filter: ec2

0 comments on commit b33fc41

Please sign in to comment.