tfctl get
The tfctl get command fetches a single resource by ID or lists resources by type.
Usage
$ tfctl get RESOURCE_OR_ID [ID] [options]
Description
The tfctl get command fetches a single resource by ID or lists resources by type. This is a convenience command that allows you to retrieve resources instead of using the tfctl api command to call specific endpoints.
Specify a resource type name, such as workspaces, and the command returns a list of all resources of that type. Specify an ID, for example ws-abc123, and the command fetches the single resource. You can also specify type and ID, for example get workspace ws-abc123.
Arguments
RESOURCE_OR_ID: (Required) Resource type name or resource ID.ID: (Optional) Resource ID. Specify when the first argument is the resource type.
Flags
--all: Paginate through all results. Fetches all pages of results automatically.- Optional.
- Data type: boolean
- Default value:
false
--organization=NAME,-o=NAME: Organization name.- Optional.
- Data type: string
- Default value: Auto-resolved from profile or Terraform
cloudconfiguration
--page-number=NUMBER,-n=NUMBER: Page number to fetch. The index starts at1. Ignored if--allis set.- Optional.
- Data type: number
- Default value:
1
--page-size=NUMBER,-s=NUMBER: Number of results per page. Ignored if--allis set.- Optional.
- Data type: number
- Default value: Varies by resource
Pagination
Commands that list multiple resources are paginated. For details on pagination options and behavior, refer to Pagination.
Global flags
Refer to Global flags reference for information about flags you can use with all commands.
Examples
The following examples demonstrate how to fetch resources using the API.
List all workspaces in the active organization
The following example lists workspaces in the default organization.
$ tfctl get workspaces
Fetch a single workspace by ID
The following example fetches a single workspace using its ID.
$ tfctl get ws-abc123
Fetch a workspace by type and ID
The following example fetches a workspace by explicitly specifying the resource type and ID.
$ tfctl get workspace ws-abc123
List all workspaces (paginate through all pages)
The following example lists all workspaces by automatically paginating through all pages.
$ tfctl get workspaces --all
List workspaces with custom pagination
The following example lists workspaces with custom page size and page number.
$ tfctl get workspaces --page-size 50 --page-number 2
List workspaces in a specific organization
The following example lists workspaces in a specific organization.
$ tfctl get workspaces -o my-org