# Your First Project

Source: https://docs.ops0.com/docs/getting-started/first-project

This guide walks you through creating your first Infrastructure as Code project in ops0 - from writing code to deploying resources.

---

## Prerequisites

Before starting, make sure you have:

- ops0 account ([Sign up here](https://docs.ops0.com/docs/getting-started/authentication))

- Cloud provider connected ([Connect AWS/GCP/Azure](https://docs.ops0.com/docs/getting-started/connect-cloud))

---

## Step 1: Create a New Project

1. Click **IaC** in the left sidebar

2. Click **+ New Project**

3. Enter project details:

| Field | Value | Notes |
|-------|-------|-------|
| **Name** | `my-first-project` | Lowercase, hyphens allowed |
| **Type** | Terraform | Or OpenTofu, Oxid. Pulumi and CloudFormation are upcoming |
| **Integration** | Your AWS/GCP/Azure | Select the cloud you connected |
| **Region** | `us-east-1` | Or your preferred region |

Click **Create Project** to continue.

---

## Step 2: Meet the Editor

The project editor has three main areas:

```
┌─────────────────────────────────────────────────────────────────┐
│  File Tree  │           Code Editor           │   AI Chat      │
│             │                                 │                │
│  main.tf    │  # Your Terraform code here    │  Ask me to     │
│  variables  │                                 │  create        │
│  outputs.tf │                                 │  infrastructure│
│             │                                 │                │
└─────────────────────────────────────────────────────────────────┘
```

File Tree

Navigate your Terraform files

Code Editor

Monaco editor with autocomplete

AI Chat

Create code with plain English

---

## Step 3: Create Your First Resource

Let's use AI to create an S3 bucket. In the **AI Chat** panel, type:

```
Create an S3 bucket with:
- Versioning enabled
- Server-side encryption (AES-256)
- Block all public access
- A lifecycle rule to move objects to Glacier after 90 days
```

ops0 will produce Terraform code like this:

```hcl
resource "aws_s3_bucket" "main" {
  bucket = "my-first-project-bucket-${random_id.suffix.hex}"

  tags = {
    Name        = "my-first-project-bucket"
    Environment = "dev"
    ManagedBy   = "ops0"
  }
}

resource "aws_s3_bucket_versioning" "main" {
  bucket = aws_s3_bucket.main.id
  versioning_configuration {
    status = "Enabled"
  }
}

resource "aws_s3_bucket_server_side_encryption_configuration" "main" {
  bucket = aws_s3_bucket.main.id

  rule {
    apply_server_side_encryption_by_default {
      sse_algorithm = "AES256"
    }
  }
}

resource "aws_s3_bucket_public_access_block" "main" {
  bucket = aws_s3_bucket.main.id

  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}

resource "aws_s3_bucket_lifecycle_configuration" "main" {
  bucket = aws_s3_bucket.main.id

  rule {
    id     = "glacier-transition"
    status = "Enabled"

    transition {
      days          = 90
      storage_class = "GLACIER"
    }
  }
}

resource "random_id" "suffix" {
  byte_length = 4
}
```

Click **Accept** to add this code to your project.

---

## Step 4: Review and Customize

The code appears in `main.tf`. You can:

- **Edit directly** - Modify the code in the editor
- **Ask AI to adjust** - "Change the bucket name to `company-data-archive`"
- **Add more resources** - "Add an IAM policy that allows read access from my application"

### Pro Tips

Be Specific

"Create a VPC" gives basic results. "Create a VPC with 3 AZs, public/private subnets, and NAT gateways" gives production-ready code.

Iterate

Start simple, then ask for additions. "Now add CloudWatch alarms for the bucket size."

---

## Step 5: Run a Plan

Before deploying, preview what will change:

1. Click the **Plan** button in the top toolbar

2. Wait for Terraform to initialize and produce a plan

3. Review the plan output

### Understanding the Plan

```
Terraform will perform the following actions:

  # aws_s3_bucket.main will be created
  + resource "aws_s3_bucket" "main" {
      + bucket = "my-first-project-bucket-a1b2c3d4"
      + ...
    }

  # aws_s3_bucket_versioning.main will be created
  + resource "aws_s3_bucket_versioning" "main" {
      + bucket = (known after apply)
      + ...
    }

Plan: 6 to add, 0 to change, 0 to destroy.
```

| Symbol | Meaning |
|--------|---------|
| `+` | Resource will be created |
| `~` | Resource will be modified |
| `-` | Resource will be destroyed |
| `-/+` | Resource will be replaced (destroy then create) |

---

## Step 6: Check Policy & Cost

After the plan, ops0 automatically runs:

### Policy Check

All Policies Passed

✓ S3 bucket has encryption enabled

✓ S3 bucket blocks public access

✓ All resources have required tags

If a policy fails, you'll see what to fix before deploying.

### Cost Estimation

| Resource | Type | Monthly Cost |
|----------|------|--------------|
| S3 Bucket | Standard | $0.023/GB |
| S3 Versioning | Per version | Included |
| **Estimated Total** | | **~$2.30** (for 100GB) |

---

## Step 7: Apply the Changes

Ready to create the resources? Click **Apply**.

1. Click **Apply** in the plan view

2. Confirm by typing the project name (for production environments)

3. Watch the real-time logs as resources are created

### Apply Output

```
aws_s3_bucket.main: Creating...
aws_s3_bucket.main: Creation complete after 2s [id=my-first-project-bucket-a1b2c3d4]
aws_s3_bucket_versioning.main: Creating...
aws_s3_bucket_versioning.main: Creation complete after 1s
...

Apply complete! Resources: 6 added, 0 changed, 0 destroyed.
```

---

## Step 8: View Your Resources

After a successful apply:

[Resource Graph See your S3 bucket and related resources visualized as a graph](https://docs.ops0.com/docs/resource-graph)

AWS Console

Your bucket is now live in S3 with all the configurations applied

---

## What's Next?

[Sync with GitHub Enable GitOps workflows for your project](https://docs.ops0.com/docs/iac/github-sync)
[Set Up GitOps PR-based deployment workflow guide](https://docs.ops0.com/docs/how-to/setup-gitops)
[Add Policies Enforce standards across all projects](https://docs.ops0.com/docs/policies/overview)
[Automate with Workflows Schedule deployments and add approvals](https://docs.ops0.com/docs/workflows/overview)

---

## Cleanup (Optional)

To delete the resources you just created:

1. Open your project

2. Click **Destroy** in the toolbar

3. Confirm by typing the project name

4. All resources will be deleted from AWS

This prevents any ongoing charges for resources you created while learning.
