1. Packages
  2. Oracle Cloud Infrastructure
  3. API Docs
  4. Bastion
  5. getSession
Oracle Cloud Infrastructure v2.30.0 published on Monday, Apr 14, 2025 by Pulumi

oci.Bastion.getSession

Explore with Pulumi AI

Oracle Cloud Infrastructure v2.30.0 published on Monday, Apr 14, 2025 by Pulumi

This data source provides details about a specific Session resource in Oracle Cloud Infrastructure Bastion service.

Retrieves a session identified by the session ID. A bastion session lets authorized users connect to a target resource for a predetermined amount of time.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as oci from "@pulumi/oci";

const testSession = oci.Bastion.getSession({
    sessionId: testSessionOciBastionSession.id,
});
Copy
import pulumi
import pulumi_oci as oci

test_session = oci.Bastion.get_session(session_id=test_session_oci_bastion_session["id"])
Copy
package main

import (
	"github.com/pulumi/pulumi-oci/sdk/v2/go/oci/bastion"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := bastion.GetSession(ctx, &bastion.GetSessionArgs{
			SessionId: testSessionOciBastionSession.Id,
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Oci = Pulumi.Oci;

return await Deployment.RunAsync(() => 
{
    var testSession = Oci.Bastion.GetSession.Invoke(new()
    {
        SessionId = testSessionOciBastionSession.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.oci.Bastion.BastionFunctions;
import com.pulumi.oci.Bastion.inputs.GetSessionArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var testSession = BastionFunctions.getSession(GetSessionArgs.builder()
            .sessionId(testSessionOciBastionSession.id())
            .build());

    }
}
Copy
variables:
  testSession:
    fn::invoke:
      function: oci:Bastion:getSession
      arguments:
        sessionId: ${testSessionOciBastionSession.id}
Copy

Using getSession

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getSession(args: GetSessionArgs, opts?: InvokeOptions): Promise<GetSessionResult>
function getSessionOutput(args: GetSessionOutputArgs, opts?: InvokeOptions): Output<GetSessionResult>
Copy
def get_session(session_id: Optional[str] = None,
                opts: Optional[InvokeOptions] = None) -> GetSessionResult
def get_session_output(session_id: Optional[pulumi.Input[str]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetSessionResult]
Copy
func GetSession(ctx *Context, args *GetSessionArgs, opts ...InvokeOption) (*GetSessionResult, error)
func GetSessionOutput(ctx *Context, args *GetSessionOutputArgs, opts ...InvokeOption) GetSessionResultOutput
Copy

> Note: This function is named GetSession in the Go SDK.

public static class GetSession 
{
    public static Task<GetSessionResult> InvokeAsync(GetSessionArgs args, InvokeOptions? opts = null)
    public static Output<GetSessionResult> Invoke(GetSessionInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetSessionResult> getSession(GetSessionArgs args, InvokeOptions options)
public static Output<GetSessionResult> getSession(GetSessionArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: oci:Bastion/getSession:getSession
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

SessionId This property is required. string
The unique identifier (OCID) of the session.
SessionId This property is required. string
The unique identifier (OCID) of the session.
sessionId This property is required. String
The unique identifier (OCID) of the session.
sessionId This property is required. string
The unique identifier (OCID) of the session.
session_id This property is required. str
The unique identifier (OCID) of the session.
sessionId This property is required. String
The unique identifier (OCID) of the session.

getSession Result

The following output properties are available:

BastionId string
The unique identifier (OCID) of the bastion that is hosting this session.
BastionName string
The name of the bastion that is hosting this session.
BastionPublicHostKeyInfo string
The public key of the bastion host. You can use this to verify that you're connecting to the correct bastion.
BastionUserName string
The username that the session uses to connect to the target resource.
DisplayName string
The name of the session.
Id string
The unique identifier (OCID) of the session, which can't be changed after creation.
KeyDetails List<GetSessionKeyDetail>
Public key details for a bastion session.
KeyType string
The type of the key used to connect to the session. PUB is a standard public key in OpenSSH format.
LifecycleDetails string
A message describing the current session state in more detail.
SessionId string
SessionTtlInSeconds int
The amount of time the session can remain active.
SshMetadata Dictionary<string, string>
The connection message for the session.
State string
The current state of the session.
TargetResourceDetails List<GetSessionTargetResourceDetail>
Details about a bastion session's target resource.
TimeCreated string
The time the session was created. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
TimeUpdated string
The time the session was updated. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
BastionId string
The unique identifier (OCID) of the bastion that is hosting this session.
BastionName string
The name of the bastion that is hosting this session.
BastionPublicHostKeyInfo string
The public key of the bastion host. You can use this to verify that you're connecting to the correct bastion.
BastionUserName string
The username that the session uses to connect to the target resource.
DisplayName string
The name of the session.
Id string
The unique identifier (OCID) of the session, which can't be changed after creation.
KeyDetails []GetSessionKeyDetail
Public key details for a bastion session.
KeyType string
The type of the key used to connect to the session. PUB is a standard public key in OpenSSH format.
LifecycleDetails string
A message describing the current session state in more detail.
SessionId string
SessionTtlInSeconds int
The amount of time the session can remain active.
SshMetadata map[string]string
The connection message for the session.
State string
The current state of the session.
TargetResourceDetails []GetSessionTargetResourceDetail
Details about a bastion session's target resource.
TimeCreated string
The time the session was created. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
TimeUpdated string
The time the session was updated. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
bastionId String
The unique identifier (OCID) of the bastion that is hosting this session.
bastionName String
The name of the bastion that is hosting this session.
bastionPublicHostKeyInfo String
The public key of the bastion host. You can use this to verify that you're connecting to the correct bastion.
bastionUserName String
The username that the session uses to connect to the target resource.
displayName String
The name of the session.
id String
The unique identifier (OCID) of the session, which can't be changed after creation.
keyDetails List<GetSessionKeyDetail>
Public key details for a bastion session.
keyType String
The type of the key used to connect to the session. PUB is a standard public key in OpenSSH format.
lifecycleDetails String
A message describing the current session state in more detail.
sessionId String
sessionTtlInSeconds Integer
The amount of time the session can remain active.
sshMetadata Map<String,String>
The connection message for the session.
state String
The current state of the session.
targetResourceDetails List<GetSessionTargetResourceDetail>
Details about a bastion session's target resource.
timeCreated String
The time the session was created. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
timeUpdated String
The time the session was updated. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
bastionId string
The unique identifier (OCID) of the bastion that is hosting this session.
bastionName string
The name of the bastion that is hosting this session.
bastionPublicHostKeyInfo string
The public key of the bastion host. You can use this to verify that you're connecting to the correct bastion.
bastionUserName string
The username that the session uses to connect to the target resource.
displayName string
The name of the session.
id string
The unique identifier (OCID) of the session, which can't be changed after creation.
keyDetails GetSessionKeyDetail[]
Public key details for a bastion session.
keyType string
The type of the key used to connect to the session. PUB is a standard public key in OpenSSH format.
lifecycleDetails string
A message describing the current session state in more detail.
sessionId string
sessionTtlInSeconds number
The amount of time the session can remain active.
sshMetadata {[key: string]: string}
The connection message for the session.
state string
The current state of the session.
targetResourceDetails GetSessionTargetResourceDetail[]
Details about a bastion session's target resource.
timeCreated string
The time the session was created. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
timeUpdated string
The time the session was updated. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
bastion_id str
The unique identifier (OCID) of the bastion that is hosting this session.
bastion_name str
The name of the bastion that is hosting this session.
bastion_public_host_key_info str
The public key of the bastion host. You can use this to verify that you're connecting to the correct bastion.
bastion_user_name str
The username that the session uses to connect to the target resource.
display_name str
The name of the session.
id str
The unique identifier (OCID) of the session, which can't be changed after creation.
key_details Sequence[bastion.GetSessionKeyDetail]
Public key details for a bastion session.
key_type str
The type of the key used to connect to the session. PUB is a standard public key in OpenSSH format.
lifecycle_details str
A message describing the current session state in more detail.
session_id str
session_ttl_in_seconds int
The amount of time the session can remain active.
ssh_metadata Mapping[str, str]
The connection message for the session.
state str
The current state of the session.
target_resource_details Sequence[bastion.GetSessionTargetResourceDetail]
Details about a bastion session's target resource.
time_created str
The time the session was created. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
time_updated str
The time the session was updated. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
bastionId String
The unique identifier (OCID) of the bastion that is hosting this session.
bastionName String
The name of the bastion that is hosting this session.
bastionPublicHostKeyInfo String
The public key of the bastion host. You can use this to verify that you're connecting to the correct bastion.
bastionUserName String
The username that the session uses to connect to the target resource.
displayName String
The name of the session.
id String
The unique identifier (OCID) of the session, which can't be changed after creation.
keyDetails List<Property Map>
Public key details for a bastion session.
keyType String
The type of the key used to connect to the session. PUB is a standard public key in OpenSSH format.
lifecycleDetails String
A message describing the current session state in more detail.
sessionId String
sessionTtlInSeconds Number
The amount of time the session can remain active.
sshMetadata Map<String>
The connection message for the session.
state String
The current state of the session.
targetResourceDetails List<Property Map>
Details about a bastion session's target resource.
timeCreated String
The time the session was created. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z
timeUpdated String
The time the session was updated. Format is defined by RFC3339. Example: 2020-01-25T21:10:29.600Z

Supporting Types

GetSessionKeyDetail

PublicKeyContent This property is required. string
The public key in OpenSSH format of the SSH key pair for the session. When you connect to the session, you must provide the private key of the same SSH key pair.
PublicKeyContent This property is required. string
The public key in OpenSSH format of the SSH key pair for the session. When you connect to the session, you must provide the private key of the same SSH key pair.
publicKeyContent This property is required. String
The public key in OpenSSH format of the SSH key pair for the session. When you connect to the session, you must provide the private key of the same SSH key pair.
publicKeyContent This property is required. string
The public key in OpenSSH format of the SSH key pair for the session. When you connect to the session, you must provide the private key of the same SSH key pair.
public_key_content This property is required. str
The public key in OpenSSH format of the SSH key pair for the session. When you connect to the session, you must provide the private key of the same SSH key pair.
publicKeyContent This property is required. String
The public key in OpenSSH format of the SSH key pair for the session. When you connect to the session, you must provide the private key of the same SSH key pair.

GetSessionTargetResourceDetail

SessionType This property is required. string
The Bastion service recognizes three types of sessions, managed SSH sessions, SSH port forwarding sessions, and Dynamic SSH port forwarding sessions. Managed SSH sessions require that the target resource has an OpenSSH server and the Oracle Cloud Agent both running.
TargetResourceDisplayName This property is required. string
The display name of the target Compute instance that the session connects to.
TargetResourceFqdn This property is required. string
The Fully Qualified Domain Name of the target resource that the session connects to.
TargetResourceId This property is required. string
The unique identifier (OCID) of the target resource (a Compute instance, for example) that the session connects to.
TargetResourceOperatingSystemUserName This property is required. string
The name of the user on the target resource operating system that the session uses for the connection.
TargetResourcePort This property is required. int
The port number to connect to on the target resource.
TargetResourcePrivateIpAddress This property is required. string
The private IP address of the target resource that the session connects to.
SessionType This property is required. string
The Bastion service recognizes three types of sessions, managed SSH sessions, SSH port forwarding sessions, and Dynamic SSH port forwarding sessions. Managed SSH sessions require that the target resource has an OpenSSH server and the Oracle Cloud Agent both running.
TargetResourceDisplayName This property is required. string
The display name of the target Compute instance that the session connects to.
TargetResourceFqdn This property is required. string
The Fully Qualified Domain Name of the target resource that the session connects to.
TargetResourceId This property is required. string
The unique identifier (OCID) of the target resource (a Compute instance, for example) that the session connects to.
TargetResourceOperatingSystemUserName This property is required. string
The name of the user on the target resource operating system that the session uses for the connection.
TargetResourcePort This property is required. int
The port number to connect to on the target resource.
TargetResourcePrivateIpAddress This property is required. string
The private IP address of the target resource that the session connects to.
sessionType This property is required. String
The Bastion service recognizes three types of sessions, managed SSH sessions, SSH port forwarding sessions, and Dynamic SSH port forwarding sessions. Managed SSH sessions require that the target resource has an OpenSSH server and the Oracle Cloud Agent both running.
targetResourceDisplayName This property is required. String
The display name of the target Compute instance that the session connects to.
targetResourceFqdn This property is required. String
The Fully Qualified Domain Name of the target resource that the session connects to.
targetResourceId This property is required. String
The unique identifier (OCID) of the target resource (a Compute instance, for example) that the session connects to.
targetResourceOperatingSystemUserName This property is required. String
The name of the user on the target resource operating system that the session uses for the connection.
targetResourcePort This property is required. Integer
The port number to connect to on the target resource.
targetResourcePrivateIpAddress This property is required. String
The private IP address of the target resource that the session connects to.
sessionType This property is required. string
The Bastion service recognizes three types of sessions, managed SSH sessions, SSH port forwarding sessions, and Dynamic SSH port forwarding sessions. Managed SSH sessions require that the target resource has an OpenSSH server and the Oracle Cloud Agent both running.
targetResourceDisplayName This property is required. string
The display name of the target Compute instance that the session connects to.
targetResourceFqdn This property is required. string
The Fully Qualified Domain Name of the target resource that the session connects to.
targetResourceId This property is required. string
The unique identifier (OCID) of the target resource (a Compute instance, for example) that the session connects to.
targetResourceOperatingSystemUserName This property is required. string
The name of the user on the target resource operating system that the session uses for the connection.
targetResourcePort This property is required. number
The port number to connect to on the target resource.
targetResourcePrivateIpAddress This property is required. string
The private IP address of the target resource that the session connects to.
session_type This property is required. str
The Bastion service recognizes three types of sessions, managed SSH sessions, SSH port forwarding sessions, and Dynamic SSH port forwarding sessions. Managed SSH sessions require that the target resource has an OpenSSH server and the Oracle Cloud Agent both running.
target_resource_display_name This property is required. str
The display name of the target Compute instance that the session connects to.
target_resource_fqdn This property is required. str
The Fully Qualified Domain Name of the target resource that the session connects to.
target_resource_id This property is required. str
The unique identifier (OCID) of the target resource (a Compute instance, for example) that the session connects to.
target_resource_operating_system_user_name This property is required. str
The name of the user on the target resource operating system that the session uses for the connection.
target_resource_port This property is required. int
The port number to connect to on the target resource.
target_resource_private_ip_address This property is required. str
The private IP address of the target resource that the session connects to.
sessionType This property is required. String
The Bastion service recognizes three types of sessions, managed SSH sessions, SSH port forwarding sessions, and Dynamic SSH port forwarding sessions. Managed SSH sessions require that the target resource has an OpenSSH server and the Oracle Cloud Agent both running.
targetResourceDisplayName This property is required. String
The display name of the target Compute instance that the session connects to.
targetResourceFqdn This property is required. String
The Fully Qualified Domain Name of the target resource that the session connects to.
targetResourceId This property is required. String
The unique identifier (OCID) of the target resource (a Compute instance, for example) that the session connects to.
targetResourceOperatingSystemUserName This property is required. String
The name of the user on the target resource operating system that the session uses for the connection.
targetResourcePort This property is required. Number
The port number to connect to on the target resource.
targetResourcePrivateIpAddress This property is required. String
The private IP address of the target resource that the session connects to.

Package Details

Repository
oci pulumi/pulumi-oci
License
Apache-2.0
Notes
This Pulumi package is based on the oci Terraform Provider.
Oracle Cloud Infrastructure v2.30.0 published on Monday, Apr 14, 2025 by Pulumi