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

Cherry-pick #19423 to 7.x: [MetricBeat] add param aws_partition to support aws-cn, aws-us-gov regions #19519

Merged
merged 4 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ field. You can revert this change by configuring tags for the module and omittin
- Add dashboards for googlecloud load balancing metricset. {pull}18369[18369]
- Update Couchbase to version 6.5 {issue}18595[18595] {pull}19055[19055]
- Add support for v1 consumer API in Cloud Foundry module, use it by default. {pull}19268[19268]
- Add param `aws_partition` to support aws-cn, aws-us-gov regions. {issue}18850[18850] {pull}19423[19423]

*Packetbeat*

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ require (
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5
golang.org/x/text v0.3.2
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f
golang.org/x/tools v0.0.0-20200630154851-b2d8b0336632
google.golang.org/api v0.15.0
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb
google.golang.org/grpc v1.29.1
Expand Down
1 change: 1 addition & 0 deletions x-pack/libbeat/common/aws/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type ConfigAWS struct {
SharedCredentialFile string `config:"shared_credential_file"`
Endpoint string `config:"endpoint"`
RoleArn string `config:"role_arn"`
AWSPartition string `config:"aws_partition"`
}

// GetAWSCredentials function gets aws credentials from the config.
Expand Down
1 change: 1 addition & 0 deletions x-pack/libbeat/docs/aws-credentials-config.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ To configure AWS credentials, either put the credentials into the {beatname_uc}
* *shared_credential_file*: directory of the shared credentials file.
* *endpoint*: URL of the entry point for an AWS web service.
* *role_arn*: AWS IAM Role to assume.
* *aws_partition*: AWS region parttion name, value is one of `aws, aws-cn, aws-us-gov`, default is `aws`.

[float]
==== Supported Formats
Expand Down
12 changes: 10 additions & 2 deletions x-pack/metricbeat/module/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,16 @@ func NewMetricSet(base mb.BaseMetricSet) (*MetricSet, error) {
base.Logger().Debug("Metricset level config for period: ", metricSet.Period)
base.Logger().Debug("Metricset level config for tags filter: ", metricSet.TagsFilter)

// Get IAM account name
awsConfig.Region = "us-east-1"
// 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
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"
}
svcIam := iam.New(awscommon.EnrichAWSConfigWithEndpoint(
config.AWSConfig.Endpoint, "iam", "", awsConfig))
req := svcIam.ListAccountAliasesRequest(&iam.ListAccountAliasesInput{})
Expand Down