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

support for aws-cli credential_process #119

Closed
diegoroccia opened this issue Aug 4, 2023 · 7 comments
Closed

support for aws-cli credential_process #119

diegoroccia opened this issue Aug 4, 2023 · 7 comments
Labels
triaged triaged into Okta's Jira backlog v2-headless will be addressed in v2 headless release

Comments

@diegoroccia
Copy link

diegoroccia commented Aug 4, 2023

I would like to hook okta-aws-cli as credential_process to the aws cli. reference: https://docs.aws.amazon.com/sdkref/latest/guide/feature-process-credentials.html

this way I can use my aws cli directly without having to run a separate command to get the credentials via okta-aws-cli

This is how saml2aws implements it:

https://github.com/Versent/saml2aws#using-saml2aws-as-credential-process

So what we would need is

a flag --credential-process generating an output with the right JSON format, as well as a flag --quiet that will block the logging from being displayed

@lw-cchapin
Copy link

#110

@monde monde added the v2-headless will be addressed in v2 headless release label Aug 29, 2023
@monde
Copy link
Collaborator

monde commented Aug 29, 2023

I was looking at https://docs.aws.amazon.com/sdkref/latest/guide/feature-process-credentials.html when I originally implemented okta-aws-cli. At the time the okta-aws-cli required user input so implementing process credentials with not possible because I found the AWS CLI completely swallows stdout/stderr. Since then I think it's possible to run okta-aws-cli without human input if the IdP and Role pre-select flags are used in otka-aws-cli . Also, I'm working on a headless feature for okta-aws-cli so this would be a good time to add process-credentials suport.

@monde
Copy link
Collaborator

monde commented Aug 29, 2023

Okta internal reference: https://oktainc.atlassian.net/browse/OKTA-642837

@monde monde added the triaged triaged into Okta's Jira backlog label Aug 29, 2023
MikeMondragon-okta pushed a commit that referenced this issue Oct 2, 2023
@jkiang13
Copy link

I've been using this as a workaround for this in okta-aws-cli v1.x. It translates the export commands to JSON via awk.

[profile okta-aws-cli-test]
credential_process=/bin/sh -c 'okta-aws-cli --org-domain <org_domain> --oidc-client-id <oidc_client_id> --open-browser true | awk '\''BEGIN {RS = ""} {gsub("\n","\",")sub("export AWS_ACCESS_KEY_ID=","\"AccessKeyId\":\"")sub("export AWS_SECRET_ACCESS_KEY=","\"SecretAccessKey\":\"")sub("export AWS_SESSION_TOKEN=","\"SessionToken\":\"")} {print "{\"Version\":1," $0 "\"}"}'\'''

@monde
Copy link
Collaborator

monde commented Jan 18, 2024

Cool work around on v1 @jkiang13
fwiw, v2 is GA'ing next week and we have "Process credential provider output as JSON" feature, you can see more in the beta notes:
https://github.com/okta/okta-aws-cli/releases/tag/v2.0.0-beta.6

@bitle
Copy link

bitle commented Feb 12, 2024

I tried the most reset v2 version and I'm running into this error message:

okta-aws-cli web --format process-credentials --oidc-client-id <client-id> --org-domain <domain> --aws-acct-fed-app-id <fed-app-id> --open-browser
Error: arguments --aws-iam-idp , --aws-iam-role , and --open-browser must be set for "process-credentials" format

If I follow the answer above to generate process-credentials with awk it works fine.

@monde
Copy link
Collaborator

monde commented Feb 12, 2024

Process credential support is the v2 release, but it has a bug if you try to combine it with also writing the credential file that has been fixed. That bug is fixed and will be released later this week.

Here's an example of how I run int in my local env:

# ~/.aws/credentials
[default]
credential_process = okta-aws-cli web --format process-credentials --oidc-client-id abc --org-domain test.okta.com --aws-iam-idp arn:aws:iam::123:saml-provider/My_IdP --aws-iam-role arn:aws:iam::123:role/S3_Read --open-browser --write-aws-credentials

I should have closed this issue with the v2 release.

@monde monde closed this as completed Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged triaged into Okta's Jira backlog v2-headless will be addressed in v2 headless release
Projects
None yet
Development

No branches or pull requests

5 participants