Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated AWS config options #28120

Merged
merged 3 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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