Note:

Resolve the ‘Cannot show information: Failed to get API session’ Error when using the OCI CLI Network Commands

Introduction

Encountering the Cannot show information: Failed to get API session error when using Oracle Cloud Infrastructure Command Line Interface (OCI CLI) network commands on Oracle Cloud Infrastructure (OCI) Compute instance can be frustrating, especially when you are managing critical network configurations.

image

In this tutorial, we will walk you through the common cause of this issue and provide step-by-step instructions to resolve it.

When Does This Error Occur?

The sudo oci-network-config show and sudo oci-network-config configure commands are part of the OCI networking utilities. These commands are used to manage and troubleshoot networking configurations in environments that interact with OCI.

For example: Run the sudo oci-network-config show command and we will get the following error: Cannot show information: Failed to get API session.

  1. Run the sudo oci-network-config show command to retrieve all network configurations from the instance.
  2. Note the error: Cannot show information: Failed to get API session. The information regarding the VNICs of the instance will not be provided on the Operating System level and not on the OCI level.

image

This is not possible as we will get the same error when we run the command oci-network-config show that is Cannot show information: Failed to get API session.

Why are we getting this error?

To enable an OCI Compute instance to fetch VCN details through API, follow the steps:

  1. Create a Dynamic Group: This dynamic group includes the instance(s) that require access to the API. You define the group using rules based on attributes like instance OCID or compartment.

  2. Assign Permissions with a Policy: You need to create an Oracle Cloud Infrastructure Identity and Access Management (OCI IAM) policy that grants the dynamic group permission to read or manage VCN-related resources. For example:

    allow dynamic-group <dynamic-group-name> to read virtual-network-family in compartment <compartment-name>
    
  3. Use Instance, Principals, for Authentication: Instances in the dynamic group authenticate directly using their identity, allowing secure API access without embedding credentials in the application. This method simplifies security management while maintaining robust access control.

Objectives

Prerequisites

Resolve the Error

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.