Skip to content
Back to skills

2281 Terraform F17c75d0

ASecurity

``` modules/ └── service/ ├── main.tf ├── variables.tf ├── outputs.tf └── versions.tf environments/ ├── dev/ │ ├── main.tf │ ├── backend.tf │ └── terraform.tfvars └── prod/ ├── main.tf ├── backend.tf └── terraform.tfvars ```

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
devopsgobashawsgcpterraformapidatabasebackend

Works with

  • api

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 2281-terraform_f17c75d0 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 2281 Terraform F17c75d0?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 2281 Terraform F17c75d0
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-2281-terraform-f17c75d0/badge)](https://www.skillsdirectory.com/skills/tools-only-2281-terraform-f17c75d0)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# Terraform Patterns

## Module Structure

```
modules/
└── service/
    ├── main.tf
    ├── variables.tf
    ├── outputs.tf
    └── versions.tf
environments/
├── dev/
│   ├── main.tf
│   ├── backend.tf
│   └── terraform.tfvars
└── prod/
    ├── main.tf
    ├── backend.tf
    └── terraform.tfvars
```

## Module Pattern

### modules/service/main.tf

```hcl
resource "google_cloud_run_service" "main" {
  name     = var.name
  location = var.region

  template {
    spec {
      containers {
        image = var.image

        resources {
          limits = {
            cpu    = var.cpu
            memory = var.memory
          }
        }
      }
    }
  }

  traffic {
    percent         = 100
    latest_revision = true
  }
}
```

### modules/service/variables.tf

```hcl
variable "name" {
  description = "Service name"
  type        = string
}

variable "region" {
  description = "GCP region"
  type        = string
  default     = "us-central1"
}

variable "image" {
  description = "Container image"
  type        = string
}

variable "cpu" {
  description = "CPU limit"
  type        = string
  default     = "1000m"
}

variable "memory" {
  description = "Memory limit"
  type        = string
  default     = "512Mi"
}
```

### modules/service/outputs.tf

```hcl
output "url" {
  description = "Service URL"
  value       = google_cloud_run_service.main.status[0].url
}

output "name" {
  description = "Service name"
  value       = google_cloud_run_service.main.name
}
```

## Environment Usage

### environments/prod/main.tf

```hcl
module "api" {
  source = "../../modules/service"

  name   = "api"
  region = "us-central1"
  image  = "gcr.io/myproject/api:${var.api_version}"
  cpu    = "2000m"
  memory = "1Gi"
}
```

### environments/prod/backend.tf

```hcl
terraform {
  backend "gcs" {
    bucket = "myproject-terraform-state"
    prefix = "prod"
  }
}
```

## Best Practices

### Naming

```hcl
# Let provider generate names
resource "google_storage_bucket" "main" {
  name_prefix = "myapp-data-"
  location    = var.region
}

# Not hardcoded
resource "google_storage_bucket" "bad" {
  name     = "myapp-data-bucket"  # Avoid
  location = var.region
}
```

### Tagging

```hcl
locals {
  common_tags = {
    Environment = var.environment
    Project     = var.project_name
    ManagedBy   = "terraform"
  }
}

resource "aws_instance" "main" {
  ami           = var.ami
  instance_type = var.instance_type
  tags          = merge(local.common_tags, { Name = "web-server" })
}
```

### Data Sources

```hcl
data "google_project" "current" {}

data "google_compute_zones" "available" {
  region = var.region
}
```

### Sensitive Outputs

```hcl
output "database_password" {
  value     = random_password.db.result
  sensitive = true
}
```

## Commands

```bash
terraform init          # Initialize
terraform plan          # Preview
terraform apply         # Apply
terraform destroy       # Destroy

terraform fmt           # Format
terraform validate      # Validate

terraform state list    # List resources
terraform state show    # Show resource
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…