-
Notifications
You must be signed in to change notification settings - Fork 181
Update SQL CLI to use AWS session token. #918
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
Update SQL CLI to use AWS session token. #918
Conversation
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Codecov Report
@@ Coverage Diff @@
## 2.x #918 +/- ##
============================================
- Coverage 97.90% 95.10% -2.81%
Complexity 3072 3072
============================================
Files 293 303 +10
Lines 7588 8246 +658
Branches 490 609 +119
============================================
+ Hits 7429 7842 +413
- Misses 158 350 +192
- Partials 1 54 +53
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
penghuo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change!
acarbonetto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Yury-Fridlyand [email protected]
Description
How to test:
Prepare
1. Create a cluster in the cloud and configure AWS_SIGv4 authentication for it
2. Create authentication key pair -
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY- that is your permanent keys3. Install AWSCLI:
sudo apt-get install awsclior
brew install awscliif this doesn't work, try
pip3 install --upgrade awscli4. Configure it
awscli configureor if you installed it using
pippython3 -m awscli configureEnter your access key, secret key and region
5. Get the token
Run
awscli sts get-session-tokenthe output is like
{ "Credentials": { "AccessKeyId": "...", "SecretAccessKey": "...", "SessionToken": "...", "Expiration": "2022-10-15T04:31:24Z" } }Record your temporary keys and session token.
6. Checkout my branch
7. Configure environment
Follow the guide https://github.com/opensearch-project/sql/blob/2.x/sql-cli/development_guide.md#development-environment-set-up
Test 1.
1. Check credentials
Ensure that
~/.aws/credentialscontainsdefaultprofile with your permanent keys, no session token yet there.2. Run SQL CLI
opensearchsql --aws-auth https://<cluster>:443Test 2.
1. Record your new credentials
Run
awscli configureand enter your temporary access and secret keys, or edit
~/.aws/credentialsmanually, replace your permanent keys by temporary ones2. Add
session_tokenAdd line
aws_session_token = ...to
~/.aws/credentials3. Verify session token authentication
awscli es list-domain-names4. Run SQL CLI
opensearchsql --aws-auth https://<cluster>:443Test 3.
1. Unset credentials
Comment out (
#) or delete all lines in~/.aws/credentialsor move/delete the file2. Set credentials in env vars
run
with your permanent keys
3. Run SQL CLI
opensearchsql --aws-auth https://<cluster>:443Test 4.
1. Unset credentials
Comment out (
#) or delete all lines in~/.aws/credentialsor move/delete the file2. Set credentials in env vars
run
with your temporary keys and session token
3. Run SQL CLI
opensearchsql --aws-auth https://<cluster>:443Notes
~/.aws/credentialsand in env vars, last one is used.defaultprofile is used only.Limitations
No option yet to specify
profile, keys and token in command line. That is easy to add.Issues Resolved
fixes #854
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.