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

Add AWS_SHARED_CREDENTIALS_FILE to get aws config #14178

Merged
merged 7 commits into from
Oct 24, 2019
Merged

Add AWS_SHARED_CREDENTIALS_FILE to get aws config #14178

merged 7 commits into from
Oct 24, 2019

Conversation

kaiyan-sheng
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng commented Oct 21, 2019

shared_credential_file can be set for the path to the shared credentials file. If empty/not set, it will be default to current user's home directory. For Linux/OSX is $HOME/.aws/credentials and for Windows is %USERPROFILE%\.aws\credentials.

closes #14157

How to test this:

Copy your aws credential to some other directory or change the name. I change mine to credentials-backup instead.

case1

Enable aws module in Metricbeat and change aws.yml to:

- module: aws
  period: 300s
  metricsets:
    - ec2
  regions:
    - us-east-1
  credential_profile_name: test-mb
  shared_credential_file: /Users/kaiyansheng/.aws/credentials-backup

You should see EC2 metrics flowing into ES with no credential error.

case2

Either with specified credential_profile_name but no shared_credential_file or specified shared_credential_file but no credential_profile_name should work.

Set valid credentials under [test-mb] profile in default credential file ~/.aws/credentials and test with config below:

- module: aws
  period: 300s
  metricsets:
    - ec2
  regions:
    - us-east-1
  credential_profile_name: test-mb

case3

Set valid credentials under [default] profile in credential file ~/.aws/credentials-backup and test with config below:

- module: aws
  period: 300s
  metricsets:
    - ec2
  regions:
    - us-east-1
  shared_credential_file: /Users/kaiyansheng/.aws/credentials-backup

case4

Set valid credentials under [default] profile in default credential file ~/.aws/credentials and test with config below without credential_profile_name or shared_credential_file:

- module: aws
  period: 300s
  metricsets:
    - ec2
  regions:
    - us-east-1

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this, this will be very helpful in some scenarios!

x-pack/libbeat/common/aws/credentials.go Outdated Show resolved Hide resolved
x-pack/libbeat/common/aws/credentials.go Outdated Show resolved Hide resolved
@kaiyan-sheng kaiyan-sheng marked this pull request as ready for review October 22, 2019 23:52
@kaiyan-sheng kaiyan-sheng requested a review from a team as a code owner October 22, 2019 23:52
x-pack/libbeat/common/aws/credentials.go Outdated Show resolved Hide resolved
x-pack/libbeat/common/aws/credentials.go Outdated Show resolved Hide resolved
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this feature! There is a small extra suggestion, but it LGTM.

x-pack/libbeat/common/aws/credentials.go Outdated Show resolved Hide resolved
@jsoriano jsoriano added the test-plan Add this PR to be manual test plan label Oct 24, 2019
@kaiyan-sheng kaiyan-sheng added needs_backport PR is waiting to be backported to other branches. v7.5.0 labels Oct 24, 2019
@kaiyan-sheng kaiyan-sheng merged commit 808e492 into elastic:master Oct 24, 2019
@kaiyan-sheng kaiyan-sheng deleted the credential_file branch October 24, 2019 22:36
@kaiyan-sheng kaiyan-sheng removed the needs_backport PR is waiting to be backported to other branches. label Oct 24, 2019
kaiyan-sheng added a commit that referenced this pull request Oct 25, 2019
… config (#14228)

* Add AWS_SHARED_CREDENTIALS_FILE to get aws config (#14178)

(cherry picked from commit 808e492)

* Update changelog
kaiyan-sheng added a commit that referenced this pull request Oct 25, 2019
jorgemarey pushed a commit to jorgemarey/beats that referenced this pull request Jun 8, 2020
* Add AWS_SHARED_CREDENTIALS_FILE to get aws config
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…get aws config (elastic#14228)

* Add AWS_SHARED_CREDENTIALS_FILE to get aws config (elastic#14178)

(cherry picked from commit 133aeb1)

* Update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Integrations Label for the Integrations team test-plan Add this PR to be manual test plan v7.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS credential profiles not found when beats is started by systemd
3 participants