> For the complete documentation index, see [llms.txt](https://docs.cloudscript.ai/cloudscript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudscript.ai/cloudscript/cloudscript-cli/cli-commands.md).

# CLI Commands

## CLI Commands

### Command Structure

All Cloudscript CLI commands follow this basic structure:

```markup
cloud [command] <path> [options]
```

Where:

* `command` is one of: convert, plan, apply, destroy
* `path` is either a file path or directory path
* `options` are additional flags and parameters

### cloud convert

#### Synopsis

```markup
cloud convert <path>
```

#### Description

Converts `.cloud` configuration files into standard infrastructure code, generating Terraform, Kubernetes, and Ansible configurations.

#### Path Requirements

* If your `.cloud` file references external files (using `file()`), provide the directory containing both the `.cloud` file and referenced files
* If no external files are referenced, you can provide either the `.cloud` file path or its containing directory

#### Behavior

1. Validates the `.cloud` file syntax
2. Creates/overwrites the IaC directory
3. Generates:
   * Terraform configurations (main.tf.json)
   * Kubernetes manifests (resources.yml)
   * Ansible playbooks (playbook.yml)
4. Pre-processes any file references

#### Warning

Converting will:

1. Overwrite all existing content in the IaC directory
2. Make previously deployed resources unmanageable via `cloud destroy`

#### Example

```bash
# Converting a configuration with external files
cloud convert ./my-project

# Converting a single .cloud file
cloud convert ./my-project/service.cloud
```

### cloud plan

#### Synopsis

```html
cloud plan <path>
```

#### Description

Performs a comprehensive dry-run of your infrastructure deployment, analyzing all components:

* Terraform plan for infrastructure changes
* Kubernetes dry-run for container configurations
* Ansible check mode for configuration management

#### Capabilities

* Validates syntax and configuration
* Detects potential deployment issues
* Shows detailed change preview
* Identifies missing dependencies
* Validates network configurations
* Checks security group settings

#### Example Output

```plaintext
Planned changes:

CREATE: compute 'web_server' in infrastructure block
MODIFY: security_group 'allow_http' in infrastructure block
CREATE: deployment 'webapp' in containers block
MODIFY: service 'nginx' in configuration block
```

### cloud apply

#### Synopsis

```html
cloud apply <path> [--auto-approve]
```

#### Description

Deploys your infrastructure by executing:

1. Terraform apply for cloud resources
2. Kubernetes apply for container workloads
3. Ansible playbook for configuration management

#### Features

* Automatic SSH key management
* Network access configuration
* Security group management
* Error handling
* Progress tracking

#### Options

* `--auto-approve`:  Skip interactive approval

#### Important Notes

* Requires appropriate cloud provider credentials
* Handles both AWS and GCP deployments
* Manages dependencies between components
* Provides real-time deployment status
* Supports rollback on failure

#### Example

```bash
# Interactive deployment
cloud apply ./my-project

# Non-interactive deployment
cloud apply ./my-project --auto-approve
```

### cloud destroy

#### Synopsis

```html
cloud destroy <path> [--auto-approve]
```

#### Description

Removes all deployed infrastructure components in the correct order:

1. Removes container workloads
2. Terminates cloud resources
3. Cleans up associated configurations

#### Safety Features

* Interactive confirmation required
* Resource dependency checking
* Staged deletion process
* State verification

#### Options

* `--auto-approve`: Skip confirmation prompt

#### Example

```bash
# Interactive destruction
cloud destroy ./my-project

# Non-interactive destruction
cloud destroy ./my-project --auto-approve
```

#### Warning

The destroy command will permanently remove all resources. Ensure you have:

* Backed up any important data
* Verified the correct path
* Understood which resources will be removed
