# terraform-iac

Part of **TERRAFORM**

# Terraform Infrastructure as Code Console Guide

## Operations Overview

| Operation | Console Entry Path | Prerequisites | Description |
|---------|-------------------|--------------|------------|
| Initialize Project | Console > Projects > Create Project | Terraform CLI installed, API key configured, sufficient account permissions | Create a new Terraform project with name, description, and workspace type |
| Debug Terraform Configuration | API Tools > Terraform Explorer | Alibaba Cloud account with permissions, basic Terraform knowledge | Use Terraform Explorer to generate, edit, plan, apply, and destroy infrastructure via web UI |
| Manage Infrastructure with Best Practices | Console > Projects > Create Project | Terraform CLI installed, Git repo initialized, API token configured | Set up a project following Terraform best practices for state management and team collaboration |
| Create Terraform Workspace | Console > Terraform > Projects > Create Project | Terraform CLI installed, API token, cloud provider account access | Create a new workspace linked to a VCS repository for remote infrastructure management |

## Operation Steps

### Initialize Project

**Navigation**: Console > Projects > Create Project

**Prerequisites**:
- Terraform CLI installed
- API key configured
- Account with sufficient permissions

1. Navigate to the Terraform Cloud console  
   - Element: **Console** (link) — top navigation bar

2. Click on 'Projects' in the left sidebar  
   - Element: **Projects** (menu) — left navigation panel

3. Click the 'Create Project' button  
   - Element: **Create Project** (button) — top-right corner  
   - Notes: You may need to select a workspace type: private or shared.

4. Enter a project name and description  
   - Element: **Project Name** (text_input) — main content area  
   - Notes: The project name must be unique across your organization.

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Project Name | text_input | Yes | — | The name of your Terraform project. |
| Description | text_input | No | — | Optional description for your project. |
| Workspace Type | dropdown | Yes | Private, Shared | Determines who can access the project and its state. |

---

### Debug Terraform Configuration

**Navigation**: API Tools > Terraform Explorer

**Prerequisites**:
- An Alibaba Cloud account with appropriate permissions
- Basic understanding of Terraform and Infrastructure as Code (IaC)

1. Navigate to the Terraform Explorer page in OpenAPI Explorer  
   - Element: **Terraform Explorer** (link) — API Tools section

2. Select a cloud service and a resource type  
   - Element: **Select a cloud service** (dropdown) — top of the page

3. Click Initiate Debugging to generate a configuration file  
   - Element: **Initiate Debugging** (button) — upper-right corner of the form

4. Configure parameters in the left-side form or edit the template online  
   - Element: **Edit** (toggle) — upper-right corner of the template  
   - Notes: Turn on Edit to modify the template directly in the editor

5. Click Plan to initialize and preview the execution plan  
   - Element: **Plan** (button) — main content area  
   - Notes: This runs `terraform init` and `terraform plan` sequentially

6. Click Apply to execute the plan and create resources  
   - Element: **Apply** (button) — Apply Details tab

7. Click Plan & Apply to automatically execute the plan without confirmation  
   - Element: **Plan & Apply** (button) — main content area  
   - Notes: Runs `terraform init`, `plan`, and `apply` in sequence

8. Click Destroy Resources to release the created resources  
   - Element: **Destroy Resources** (button) — main content area  
   - Notes: Generates a destroy plan and executes it after confirmation

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Cloud Service | dropdown | Yes | — | Selects the Alibaba Cloud service for which you want to create infrastructure |
| Resource Type | dropdown | Yes | — | Selects the specific resource type within the chosen cloud service |
| Template | dropdown | No | Default Template, Sample Template 1, Sample Template 2 | Choose a pre-defined template to start from; can be edited later |
| Parameters | text_input | No | — | Enter values for configurable parameters in the selected template |

---

### Manage Infrastructure with Best Practices

**Navigation**: Console > Projects > Create Project

**Prerequisites**:
- Terraform CLI installed
- Git repository initialized
- API token configured for Terraform Cloud/Enterprise

1. Navigate to the Terraform Console  
   - Element: **Console** (link) — top navigation bar

2. Click on 'Projects' in the left sidebar  
   - Element: **Projects** (menu) — left navigation panel

3. Click the 'Create Project' button  
   - Element: **Create Project** (button) — top-right corner  
   - Notes: You must have a workspace with at least one environment to proceed.

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Project Name | text_input | Yes | — | The name of your Terraform project. Must be unique across your organization. |
| Workspace Type | dropdown | Yes | Remote (Terraform Cloud), Local (CLI only) | Choose whether this project will use remote state storage or local state files. |
| Environment | dropdown | Yes | Development, Staging, Production | Select the environment for this project. Each environment has its own state and variables. |

---

### Create Terraform Workspace

**Navigation**: Console > Terraform > Projects > Create Project

**Prerequisites**:
- Terraform CLI installed on your machine
- API token configured for authentication
- Access to a cloud provider account (e.g., AWS, Azure, GCP)

1. Navigate to the Terraform Cloud console  
   - Element: **Terraform Cloud** (link) — top navigation bar

2. Click on 'Create New Workspace'  
   - Element: **Create New Workspace** (button) — main content area

3. Select the source control provider (GitHub, GitLab, Bitbucket)  
   - Element: **Source Control Provider** (dropdown) — left panel  
   - Notes: Ensure your account is linked to the selected provider

4. Choose the repository and branch to use for configuration  
   - Element: **Repository** (dropdown) — middle section  
   - Notes: The branch must contain valid Terraform configuration files

5. Click 'Create Workspace' to finalize setup  
   - Element: **Create Workspace** (button) — bottom of form

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Workspace Name | text_input | Yes | — | A unique name for your Terraform workspace |
| Description | text_input | No | — | Optional description to help identify the purpose of the workspace |
| VCS Integration | checkbox | Yes | — | Enable version control integration with your repository |

## FAQ

Q: Where do I find the Terraform Explorer in the Alibaba Cloud console?  
A: Navigate to API Tools > Terraform Explorer. It is accessible via https://api.aliyun.com/api-tools/terraform.

Q: Can I modify the Terraform template after initiating a debugging session?  
A: Yes. Toggle the **Edit** switch in the upper-right corner of the template editor to modify the HCL code directly.

Q: What happens if I leave the "Description" field empty when creating a project?  
A: The field is optional. Leaving it blank will not affect functionality but may reduce clarity for team members.

Q: Do I need a paid Terraform Cloud account to create a project?  
A: No. Terraform Cloud offers a free tier with up to 5 workspaces and 5 users. You can create projects within these limits at no cost.

Q: Can I change the workspace type (Private/Shared) after project creation?  
A: No. The workspace type is set during project initialization and cannot be changed afterward. You would need to create a new project.

## Pricing & Billing

### Billing Model
Terraform itself is open-source and free to use. Costs arise from underlying cloud resources provisioned via Terraform. For Terraform Cloud/Enterprise, billing is based on subscription tiers.

### Price Reference

| Tier | Price | Included Features |
|------|-------|------------------|
| Free Tier | Free | Up to 5 workspaces, 500 MB storage, 5 users |
| Standard | $4–$5 per user/month | Unlimited workspaces, 10 GB storage, CI/CD integration |
| Enterprise | $10 per user/month | Advanced audit logs, SSO, dedicated support |

### Free Tier
- Terraform Cloud: 5 free workspaces and 5 users
- Terraform Explorer: Free to use with no cost for standard usage
- Local Terraform CLI: Fully open-source and free

### Billing Notes
- Billing applies only to Terraform Cloud/Enterprise usage, not the open-source CLI.
- Free tier quotas (e.g., 500 runs/month, 5 workspaces) reset monthly.
- Charges begin only after exceeding free tier limits or upgrading to a paid plan.
- Underlying cloud resources (e.g., ECS instances, VPCs) are billed separately by the cloud provider.