Listing Streams and Stream Pools

This information describes how to list streams and stream pools.

Required IAM Policy

To use Oracle Cloud Infrastructure, an administrator must be a member of a group granted security access in a policy  by a tenancy administrator. This access is required whether you're using the Console or the REST API with an SDK, CLI, or other tool. If you get a message that you don't have permission or are unauthorized, verify with the tenancy administrator what type of access you have and which compartment  your access works in.

For administrators: The policy in Let streaming admins manage streaming resources lets the specified group do everything with streaming and related Streaming service resources.

If you're new to policies, see Managing Identity Domains and Common Policies. If you want to dig deeper into writing policies for the Streaming service, see Details for the Streaming service in the IAM policy reference and Accessing Streaming Resources Across Tenancies.

Using OCI SDKs

Use the listStreams method to return a list of streams for a given compartment or stream pool. To get details about a stream, use the getStream method and then examine the properties of the stream.

See the Developer Guide to Streaming for detailed SDK examples.

Using Resource Manager

Resource Manager is an Oracle Cloud Infrastructure (OCI) service that allows you to automate the process of provisioning your OCI resources. Using Terraform, Resource Manager helps you install, configure, and manage resources through the "infrastructure-as-code" model.

A Terraform configuration codifies your infrastructure in declarative configuration files. The configuration defines the resources you intend to provision, variables, and specific instructions for provisioning the resources

You can use Resource Manager or the Terraform CLI with the OCI Terraform provider to see how your streams and stream pools are represented in Terraform configuration files.

For more information about writing configurations for use with Resource Manager, see Terraform Configurations for Resource Manager and Terraform Configuration.

Streams

If you're using Resource Manager to manage streams in a stack, the streams are represented as oci_streaming_stream resources.

For example:

resource oci_streaming_stream export_example_stream {
  compartment_id = var.compartment_ocid
  defined_tags = {
  }
  freeform_tags = {
  }
  name               = "example_stream"
  partitions         = "1"
  retention_in_hours = "24"
  #stream_pool_id = <<Optional value not found in discovery>>
}

Listing Streams

You can use the oci_streaming_streams data source to retrieve the streams in your compartment if you're using the Terraform provider.

For example:

data "oci_streaming_streams" "test_streams" {

    #Optional
    compartment_id = var.compartment_id
    id = var.stream_id
    name = var.stream_name
    state = var.stream_state
    stream_pool_id = oci_streaming_stream_pool.test_stream_pool.id
}

Stream Pools

If you're using Resource Manager to manage streams in a stack, the streams are represented as oci_streaming_stream_pool resources.

For example:

resource oci_streaming_stream_pool export_test_stream_pool {
  compartment_id = var.compartment_ocid
  name           = "test_stream_pool"

  #Optional
  private_endpoint_settings {
    nsg_ids             = [oci_core_network_security_group.test_nsg.id]
    private_endpoint_ip = "10.0.0.5"
    subnet_id           = oci_core_subnet.test_subnet.id
  }

  kafka_settings {
    #Optional
    auto_create_topics_enable = true
    log_retention_hours       = 24
    num_partitions            = 1
  }
}

resource "oci_core_vcn" "test_vcn" {
  cidr_block     = "10.0.0.0/16"
  compartment_id = var.compartment_ocid
  display_name   = "testvcn"
  dns_label      = "dnslabel"
}

resource "oci_core_subnet" "test_subnet" {
  cidr_block     = "10.0.0.0/24"
  compartment_id = var.compartment_ocid
  vcn_id         = oci_core_vcn.test_vcn.id
}

resource "oci_core_network_security_group" "test_nsg" {
  compartment_id = var.compartment_ocid
  vcn_id         = oci_core_vcn.test_vcn.id
}

Stream Details

Terraform provider users can use the oci_streaming_stream data source to retrieve the details of a stream.

For example:

data "oci_streaming_stream" "test_stream" {
  #Required
  stream_id = oci_streaming_stream.stream.id
}

Stream Pool Details

Terraform provider users can use the oci_streaming_stream_pool data source to retrieve the details of a stream pool.

For example:

data "oci_streaming_stream_pool" "test_stream_pool" {
    #Required
    stream_pool_id = oci_streaming_stream_pool.test_stream_pool.id
}