oracle / oci-cli

Command Line Interface for Oracle Cloud Infrastructure
https://cloud.oracle.com/cloud-infrastructure
Other
448 stars 185 forks source link

cli configuration file cannot feed `auth` variable to `oci os bucket list` #596

Open davidkhala opened 2 years ago

davidkhala commented 2 years ago

Enrivonment

I have setup with a CLI configuration file oci_cli_rc with session

[DEFAULT]
compartment-id=ocid1.tenancy.oc1.....
auth=instance_principal
query=data
...

What I see

running oci os bucket list, I am prompted

ERROR: Could not find config file at /home/ubuntu/.oci/config
Do you want to create a new config file? [Y/n]:

But runing oci os bucket list --auth instance_principal successs.

An runing oci iam region list successs

mandyht commented 2 years ago

What cli version are you on? (pip list | grep oci) Are you able to run oci os ns get successfully? If not, can you share the output for oci os ns get --debug?

davidkhala commented 2 years ago

@mandyht Hi Mandy, thanks for your followup. My OCI CLI version is 3.9.0 I am able to run oci os ns get successfully

davidkhala commented 2 years ago

@mandyht after upgrade to 3.18.1, this issue is reproducible still.

mandyht commented 2 years ago

Can you confirm if your config file is indeed located at /home/ubuntu/.oci/config? Does it contain the values: user, fingerprint, key_file, tenancy, and region? If you create a new config file as prompted and execute the command again, will it still prompt you to create a new one?

davidkhala commented 2 years ago

Hi @mandyht Mandy, then it will be something anti-pattern. I expect the auth=instance_principal should not require me to setup any ~/.oci/config file even if it is missing. If with a config file, that is not instance_principal. but user auth.

mandyht commented 1 year ago

If you didn't use --auth instance_principal, you will be using your config file for authentication. Which one did you intend to use?

davidkhala commented 1 year ago

@mandyht Hi Mandy, I mean the CLI configuration file should help me autofill --auth instance_principal for for CLI command. I want to use instance_principal.

davidkhala commented 1 year ago

And this should not be labeled as Object Storage only issue but a general CLI configuration file environment feed issue.

mandyht commented 1 year ago

You won't be able to setup your oci config (config) to have your auth method applied automatically, but you may be able to setup your cli config (oci_cli_rc) so it does.

Read more about cli-specific config here: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliconfigure.htm

davidkhala commented 1 year ago

Hi @mandyht It is my typo in last comment. I meant CLI config. I am using the oci_cli_rc to setup. Please double check my original post.

mandyht commented 1 year ago

Turns out it's currently not possible to set default auth value in cli-specific config. You can use export OCI_CLI_AUTH=instance_principal to avoid providing the --auth option for every command.

davidkhala commented 1 year ago

@mandyht Yes, that is why I want this issue as labelled as enhancement issue

pankajmjx commented 1 year ago

@davidkhala the command oci os bucket list gives error because it is not able to find namspace.If you are using oci_cli_rc file for getting the auth value then you should also specify namespace in the oci_cli_rc file(nampespace=xxx). The iam command works fine because it do not require any namspace.