tfctl create
The tfctl create command creates a new resource using the API.
Usage
$ tfctl create RESOURCE [options]
Description
The tfctl create command creates a new resource using the API with a simplified interface. This is a convenience command that allows you to create resources instead of using the tfctl api command to call specific endpoints.
Provide attributes using the repeatable -a key=value option or a raw request body with -i. Use -i - to read the request body from stdin.
The -a option only sets data.attributes. Resources that require a relationships block, such as variable sets or policy sets, must use -i with a full JSON:API request body.
Arguments
RESOURCE: (Required) Resource type to create. For example,workspaceorproject.
Flags
--attribute=KEY=VALUE,-a=KEY=VALUE: Attribute for the JSON:API request body. Can be repeated for multiple attributes. Cannot be used with--input. Automatically constructs a JSON:API envelope with the specified attributes.- Optional.
- Data type: string (repeatable)
- Default value: None
--input=BODY,-i=BODY: Raw JSON request body. Set to-to read from stdin. Cannot be used with--attribute.- Optional.
- Data type: string
- Default value: None
--organization=NAME,-o=NAME: Organization name.- Optional.
- Data type: string
- Default value: Auto-resolved from profile or Terraform
cloudconfiguration
Global flags
Refer to Global flags reference for information about flags you can use with all commands.
Examples
The following examples demonstrate how to create resources using the API.
Create a workspace using attributes
The following example creates a workspace using the --attribute flag to set attributes.
$ tfctl create workspace --attribute name=my-workspace
Create a workspace from a JSON file
The following example creates a workspace from a JSON file containing the full request body.
$ tfctl create workspace --input workspace.json
Create a project with inline JSON
The following example creates a project using inline JSON for the request body.
$ tfctl create project --input '{"data":{"type":"projects","attributes":{"name":"my-project"}}}'
Create a workspace in a specific organization
The following example creates a workspace in a specific organization.
$ tfctl create workspace --attribute name=my-workspace --organization my-org