# Infrastructure Blueprints

Source: https://docs.ops0.com/docs/iac/blueprints

Blueprints are pre-built Terraform templates for common infrastructure patterns. The Blueprint Wizard guides you through provider selection and parameter configuration, then generates a complete, ready-to-deploy IaC project — no code required.

**Publish your own blueprints for self-service**

Any IaC project can also be published as a blueprint using **Save as Blueprint**, making it requestable by developers through the [Developer Portal](https://docs.ops0.com/docs/developer-portal/overview) — with its own approval policy and per-variable guardrails. See [Publishing Blueprints](https://docs.ops0.com/docs/developer-portal/publishing-blueprints).

## Available Blueprints

- **Kubernetes Cluster**: EKS, GKE, or AKS with VPC/VNet, IAM, and managed node pools — production-ready from day one.

- **Database**: RDS, Cloud SQL, or Azure Database with subnet groups, security groups, backups, and optional high availability.

- **Static Website**: S3/CloudFront, GCS/Cloud CDN, or Azure Blob/CDN with SSL certificate, custom domain, and caching.

- **EMR / Data Processing**: EMR, Dataproc, or HDInsight clusters for big data workloads, with VPC, IAM, and storage configuration.

---

## Cloud Provider Support

| Blueprint | AWS | GCP | Azure |
|-----------|-----|-----|-------|
| **Kubernetes** | EKS + VPC + IAM + managed node group | GKE + VPC + service account + node pool | AKS + VNet + managed identity + node pool |
| **Database** | RDS + subnet group + security group + backups | Cloud SQL + private IP + backups + HA | Azure Database + VNet rules + geo-redundancy |
| **Static Website** | S3 + CloudFront + ACM certificate | GCS + Cloud CDN + SSL | Blob Storage + Azure CDN + custom domain |
| **Data Processing** | EMR + VPC + IAM + S3 storage | Dataproc + VPC + service account | HDInsight + VNet + managed identity |

---

## Using the Blueprint Wizard

### Open Blueprints
In the IaC section, click **New Project** and select **From Blueprint**.

### Choose a Blueprint
Select the infrastructure pattern: Kubernetes, Database, Static Website, or Data Processing.

### Select Cloud Provider
Choose AWS, GCP, or Azure. Parameter options adjust based on the provider.

### Fill in Parameters
Configure the blueprint-specific settings. Every field includes a description and a sensible default — most teams only need to change the name and region.

### Review the Generated Code
ops0 previews the complete Terraform configuration before creating the project. The preview shows:
- All generated files (`main.tf`, `variables.tf`, `outputs.tf`, `iam.tf`, `vpc.tf`)
- Estimated monthly cost for the blueprint configuration
- A summary of what will be created

If the parameters need adjusting, click **Edit Parameters** to go back to the previous step without losing your other settings.

### Create Project
Click **Create Project**. The generated code is saved as a new IaC project. From here you can edit, validate, plan, and deploy using the standard IaC workflow.

---

## Blueprint Parameters

### Kubernetes Cluster

| Parameter | Description | Default |
|-----------|-------------|---------|
| **Cluster Name** | Name for the Kubernetes cluster | — |
| **Region** | Deployment region | Provider default |
| **Kubernetes Version** | K8s version to use | Latest stable |
| **Node Count** | Number of worker nodes in the default node pool | 3 |
| **Node Size** | Instance type / machine type for nodes | t3.medium (AWS) |
| **VPC CIDR** | Network address range | 10.0.0.0/16 |
| **Enable OIDC** | Enable OIDC provider for service account IAM | true (AWS) |

**What gets created (AWS EKS example):**
- VPC with public and private subnets across two availability zones
- Internet Gateway and NAT Gateway
- EKS cluster with OIDC provider enabled
- Managed node group with the configured instance type and count
- IAM role for the cluster (eks.amazonaws.com trust policy)
- IAM role for nodes with AmazonEKSWorkerNodePolicy and AmazonEC2ContainerRegistryReadOnly
- Security groups with appropriate inbound/outbound rules

### Database

| Parameter | Description | Default |
|-----------|-------------|---------|
| **Database Name** | Identifier for the database instance | — |
| **Engine** | Database engine (PostgreSQL, MySQL, MariaDB) | PostgreSQL |
| **Engine Version** | Engine version number | Latest stable |
| **Instance Class** | Compute size | db.t3.medium |
| **Storage (GB)** | Allocated storage in gigabytes | 20 |
| **Multi-AZ** | Deploy a standby replica for high availability | false |
| **Backup Retention** | Days to retain automated backups | 7 |
| **Publicly Accessible** | Allow access from outside the VPC | false |

### Static Website

| Parameter | Description | Default |
|-----------|-------------|---------|
| **Site Name** | Name for the bucket / storage account | — |
| **Domain** | Custom domain (optional) | — |
| **Index Document** | Default document served at root | index.html |
| **Error Document** | Document served on 404 errors | error.html |
| **Enable HTTPS** | Provision and attach an SSL certificate | true |
| **Enable CDN** | Put a CDN distribution in front of storage | true |
| **Cache TTL** | CDN cache duration in seconds | 86400 |

### Data Processing (EMR / Dataproc / HDInsight)

| Parameter | Description | Default |
|-----------|-------------|---------|
| **Cluster Name** | Name for the processing cluster | — |
| **Region** | Deployment region | Provider default |
| **Master Instance Type** | Instance type for master / head node | m5.xlarge (AWS) |
| **Worker Instance Type** | Instance type for worker nodes | m5.xlarge (AWS) |
| **Worker Count** | Number of worker nodes | 2 |
| **Framework** | Processing framework (Spark, Hadoop, Flink) | Spark |

---

## Generated Project Structure

Every blueprint produces a complete, organized Terraform project:

```
project-name/
├── main.tf          # Primary resource definitions
├── variables.tf     # Input variables with types and defaults
├── outputs.tf       # Output values (endpoints, IDs, ARNs)
├── providers.tf     # Provider configuration and version constraints
└── iam.tf           # IAM roles and policies (where applicable)
```

For Kubernetes and networking-heavy blueprints, networking resources are split into a separate file:

```
project-name/
├── main.tf
├── vpc.tf           # VPC, subnets, gateways, route tables
├── iam.tf
├── variables.tf
└── outputs.tf
```

---

## Example: Kubernetes Cluster Blueprint (AWS)

### Input Parameters

| Parameter | Value |
|-----------|-------|
| Cluster Name | `production-eks` |
| Region | `us-east-1` |
| Kubernetes Version | `1.29` |
| Node Count | `3` |
| Node Size | `t3.medium` |
| VPC CIDR | `10.0.0.0/16` |

### Produced `main.tf` (excerpt)

```hcl
resource "aws_eks_cluster" "main" {
  name     = var.cluster_name
  role_arn = aws_iam_role.cluster.arn
  version  = var.kubernetes_version

  vpc_config {
    subnet_ids              = concat(aws_subnet.private[*].id, aws_subnet.public[*].id)
    endpoint_private_access = true
    endpoint_public_access  = true
  }

  depends_on = [
    aws_iam_role_policy_attachment.cluster_policy,
    aws_iam_role_policy_attachment.vpc_resource_controller,
  ]

  tags = {
    Name      = var.cluster_name
    ManagedBy = "ops0"
  }
}

resource "aws_eks_node_group" "main" {
  cluster_name    = aws_eks_cluster.main.name
  node_group_name = "${var.cluster_name}-nodes"
  node_role_arn   = aws_iam_role.node.arn
  subnet_ids      = aws_subnet.private[*].id

  scaling_config {
    desired_size = var.node_count
    max_size     = var.node_count * 2
    min_size     = 1
  }

  instance_types = [var.node_size]

  depends_on = [
    aws_iam_role_policy_attachment.node_policy,
    aws_iam_role_policy_attachment.cni_policy,
    aws_iam_role_policy_attachment.ecr_read,
  ]
}
```

### Cost Estimate Before Deploying

After the project is created, run a cost estimate in the deployment flow:

| Resource | Monthly Cost |
|----------|-------------|
| EKS Cluster control plane | $72.00 |
| 3× t3.medium EC2 nodes | $91.11 |
| NAT Gateway | $32.40 |
| **Total** | **~$195.51** |

---

## Customizing Blueprints

Blueprints are starting points, not locked templates. Once ops0 creates the IaC project from a blueprint, it behaves like any other IaC project — you can:

- Edit files directly in the editor
- Ask the AI to modify the generated code ("add a second node group for spot instances")
- Add additional resources (monitoring, logging, alerting)
- Change variable defaults in `variables.tf`
- Refactor into modules

**After Customization**

After editing blueprint-generated code, run Validate → Plan to confirm your changes are syntactically correct and produce the expected infrastructure changes before deploying.

---

## From Blueprint to Deployed Infrastructure

### Create from Blueprint
Use the wizard to generate the project.

### Review Code
Check `main.tf`, `variables.tf`, and `outputs.tf` for any values you want to adjust.

### Configure State Backend
In project settings, connect an S3 bucket, GCS bucket, or Azure Blob container for Terraform state.

### Connect Cloud Integration
Attach the AWS, GCP, or Azure integration that has deploy permissions.

### Plan
Click **Deploy → Plan** to preview exactly what will be created.

### Review Cost Estimate
Check the estimated monthly cost before committing.

### Apply
If the plan looks correct, click **Apply** to create the infrastructure.

---

## Related

- [IaC Projects](https://docs.ops0.com/docs/iac/projects): Create and manage IaC projects.

- [Deployments](https://docs.ops0.com/docs/iac/deployments): Plan, apply, and monitor infrastructure changes.

- [Replicate Projects](https://docs.ops0.com/docs/iac/replicate): Clone an existing project to a new cloud or region.

- [Cost Estimation](https://docs.ops0.com/docs/iac/deployments/cost): Understand estimated monthly costs before deploying.
