Noovolari / leapp

Leapp is the DevTool to access your cloud
https://www.leapp.cloud/
Mozilla Public License 2.0
1.6k stars 146 forks source link

leapp-cli: Use profile name and session name instead of IDs #293

Open nitrocode opened 2 years ago

nitrocode commented 2 years ago

Is your feature request related to a problem? Please describe. It's a pain point to look up the ID of a profile or session in order to use leapp session add and leapp session start

Currently

✗ leapp idp-url create --idpUrl $LEAPP_IDP_URL
identity provider URL created
✗ leapp profile create --profileName $LEAPP_PROFILE_NAME
profile created
✗ LEAPP_PROFILE_ID=$(leapp profile list -x | grep $LEAPP_PROFILE_NAME | awk '{ print $1 }' | head -1)
✗ echo $LEAPP_PROFILE_ID
7b60156a-4e35-4a0e-a2f5-94b37f35489a
✗ leapp session add \
  --providerType "aws" \
  --sessionType "awsIamRoleFederated" \
  --sessionName $LEAPP_PROFILE_ALIAS \
  --roleSessionName $LEAPP_PROFILE_ALIAS \
  --region $LEAPP_REGION \
  --roleArn $LEAPP_ROLE_ARN  \
  --idpUrl $LEAPP_IDP_URL \
  --idpArn $LEAPP_IDP_ARN \
  --profileId $LEAPP_PROFILE_ID
session added
✗ LEAPP_SESSION_ID=$(leapp session list -x --csv | grep $LEAPP_PROFILE_ALIAS | cut -d',' -f1)
✗ leapp session start --sessionId $LEAPP_SESSION_ID
session started

Describe the solution you'd like Use profile name and session name instead of IDs

This would simplify the above script

✗ leapp session add \
  --providerType "aws" \
  --sessionType "awsIamRoleFederated" \
  --sessionName $LEAPP_PROFILE_ALIAS \
  --roleSessionName $LEAPP_PROFILE_ALIAS \
  --region $LEAPP_REGION \
  --roleArn $LEAPP_ROLE_ARN  \
  --idpUrl $LEAPP_IDP_URL \
  --idpArn $LEAPP_IDP_ARN \
  --profileName $LEAPP_PROFILE_NAME
identity provider URL created
profile created
session added
✗ leapp session start --sessionName $LEAPP_PROFILE_ALIAS
session started

Describe alternatives you've considered Use a bash script like the one above in order to retrieve the profile and session IDs

Additional context

andreacavagna01 commented 2 years ago

Correct point. The session Alias by default cannot be unique, but it is way easier to remember the session to script.

Thanks for the suggestion, I think is something that can be made in the CLI function

nitrocode commented 2 years ago

@andreacavagna01 it would be nice too if this command can be run as soon as we install the leapp-cli without having to create the idp-url or profile.

I'd we provide the profile name and idp-url to leapp session add and the idp-url or profile name doesnt exist, it should just create it. That way it's nice and easy.

andreacavagna01 commented 2 years ago

@urz9999 this is working for CLI or needs to be implemented?

urz9999 commented 2 years ago

we already have the default profile, so if no profile is passed, we can use the default one, but the IdP URL must be created is something that only the user knows; there is no "default URL."

Also, because the alias is not unique, if you use the session alias to define a session, we have to implement a logic to show the user all the possible sessions to launch, and while this is usually not a problem in interactive mode, is something we must account to for scripting, and the user too.

So, in short, it must be implemented.