Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:19:34 +08:00
commit 8865a2d81c
9 changed files with 587 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
{
"name": "infrastructure-as-code-generator",
"description": "Generate Infrastructure as Code for Terraform, CloudFormation, Pulumi, and more",
"version": "1.0.0",
"author": {
"name": "Claude Code Plugins",
"email": "[email protected]"
},
"skills": [
"./skills"
],
"commands": [
"./commands"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# infrastructure-as-code-generator
Generate Infrastructure as Code for Terraform, CloudFormation, Pulumi, and more

226
commands/iac-generate.md Normal file
View File

@@ -0,0 +1,226 @@
---
description: Generate Infrastructure as Code
---
# Infrastructure as Code Generator
Generate production-ready IaC for multiple platforms and cloud providers.
## IaC Platforms Supported
1. **Terraform**: AWS, GCP, Azure infrastructure
2. **CloudFormation**: AWS native IaC
3. **Pulumi**: Multi-cloud with programming languages
4. **ARM Templates**: Azure Resource Manager
5. **CDK**: Cloud Development Kit (AWS, Terraform)
## Terraform Example (AWS ECS Fargate)
```hcl
terraform {
required_version = ">= 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
variable "environment" {
type = string
default = "production"
}
variable "app_name" {
type = string
default = "web-app"
}
# VPC Configuration
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "${var.app_name}-${var.environment}"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b", "us-east-1c"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
enable_nat_gateway = true
enable_vpn_gateway = false
tags = {
Environment = var.environment
Terraform = "true"
}
}
# ECS Cluster
resource "aws_ecs_cluster" "main" {
name = "${var.app_name}-${var.environment}"
setting {
name = "containerInsights"
value = "enabled"
}
}
# ECS Task Definition
resource "aws_ecs_task_definition" "app" {
family = "${var.app_name}"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = "256"
memory = "512"
execution_role_arn = aws_iam_role.ecs_execution.arn
task_role_arn = aws_iam_role.ecs_task.arn
container_definitions = jsonencode([
{
name = var.app_name
image = "${aws_ecr_repository.app.repository_url}:latest"
portMappings = [
{
containerPort = 8080
protocol = "tcp"
}
]
environment = [
{
name = "NODE_ENV"
value = var.environment
}
]
secrets = [
{
name = "DATABASE_URL"
valueFrom = aws_ssm_parameter.db_url.arn
}
]
logConfiguration = {
logDriver = "awslogs"
options = {
"awslogs-group" = aws_cloudwatch_log_group.app.name
"awslogs-region" = "us-east-1"
"awslogs-stream-prefix" = "ecs"
}
}
healthCheck = {
command = ["CMD-SHELL", "curl -f http://localhost:8080/health || exit 1"]
interval = 30
timeout = 5
retries = 3
startPeriod = 60
}
}
])
}
# ECS Service
resource "aws_ecs_service" "app" {
name = "${var.app_name}-service"
cluster = aws_ecs_cluster.main.id
task_definition = aws_ecs_task_definition.app.arn
desired_count = 3
launch_type = "FARGATE"
network_configuration {
subnets = module.vpc.private_subnets
security_groups = [aws_security_group.ecs_tasks.id]
assign_public_ip = false
}
load_balancer {
target_group_arn = aws_lb_target_group.app.arn
container_name = var.app_name
container_port = 8080
}
deployment_configuration {
maximum_percent = 200
minimum_healthy_percent = 100
}
depends_on = [aws_lb_listener.app]
}
# Application Load Balancer
resource "aws_lb" "app" {
name = "${var.app_name}-alb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.alb.id]
subnets = module.vpc.public_subnets
enable_deletion_protection = true
tags = {
Environment = var.environment
}
}
resource "aws_lb_target_group" "app" {
name = "${var.app_name}-tg"
port = 8080
protocol = "HTTP"
vpc_id = module.vpc.vpc_id
target_type = "ip"
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 5
interval = 30
path = "/health"
matcher = "200"
}
}
resource "aws_lb_listener" "app" {
load_balancer_arn = aws_lb.app.arn
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2016-08"
certificate_arn = aws_acm_certificate.app.arn
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.app.arn
}
}
# Auto Scaling
resource "aws_appautoscaling_target" "ecs" {
max_capacity = 10
min_capacity = 3
resource_id = "service/${aws_ecs_cluster.main.name}/${aws_ecs_service.app.name}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
}
resource "aws_appautoscaling_policy" "cpu" {
name = "cpu-autoscaling"
policy_type = "TargetTrackingScaling"
resource_id = aws_appautoscaling_target.ecs.resource_id
scalable_dimension = aws_appautoscaling_target.ecs.scalable_dimension
service_namespace = aws_appautoscaling_target.ecs.service_namespace
target_tracking_scaling_policy_configuration {
predefined_metric_specification {
predefined_metric_type = "ECSServiceAverageCPUUtilization"
}
target_value = 70.0
}
}
```
## When Invoked
Generate complete Infrastructure as Code for deploying applications on any cloud platform.

65
plugin.lock.json Normal file
View File

@@ -0,0 +1,65 @@
{
"$schema": "internal://schemas/plugin.lock.v1.json",
"pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/devops/infrastructure-as-code-generator",
"normalized": {
"repo": null,
"ref": "refs/tags/v20251128.0",
"commit": "c9517a384e68c0386988ea7bfba007479053ace3",
"treeHash": "32521136fac2e0812635dea53b6a4cfd1a51d033b2f49140c69b01ae7977244a",
"generatedAt": "2025-11-28T10:18:30.471635Z",
"toolVersion": "publish_plugins.py@0.2.0"
},
"origin": {
"remote": "git@github.com:zhongweili/42plugin-data.git",
"branch": "master",
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
},
"manifest": {
"name": "infrastructure-as-code-generator",
"description": "Generate Infrastructure as Code for Terraform, CloudFormation, Pulumi, and more",
"version": "1.0.0"
},
"content": {
"files": [
{
"path": "README.md",
"sha256": "6aa9dbef4c094ec9a4f8745dbd2d4aaedad1593825bf0ebc5d0c10d9987a0067"
},
{
"path": ".claude-plugin/plugin.json",
"sha256": "1c402da8172826c269e95109dd8c9628101232167dc1c2c6ce0b0d2ccaabaa11"
},
{
"path": "commands/iac-generate.md",
"sha256": "21fe8a1757eed00b06f03614bf0400dff2f446bcaf1da034998980a64231f53f"
},
{
"path": "skills/infrastructure-as-code-generator/SKILL.md",
"sha256": "0da4719e6f1c03006e80d14923183aff73dc38dc08aaef2e69a0041b4896f700"
},
{
"path": "skills/infrastructure-as-code-generator/references/README.md",
"sha256": "0bffe38783190d2bc72cf5dda584b86511c97383fbd23ab8979dd4a4b2a16f74"
},
{
"path": "skills/infrastructure-as-code-generator/scripts/README.md",
"sha256": "da1c1cc90928643b105347486a252f280597c03930993021e5b566864f23a843"
},
{
"path": "skills/infrastructure-as-code-generator/assets/iac_config_schema.json",
"sha256": "f1d55d0c487ab69ca9dc262d15587a1e045458d8bd5620b0f914279d440bf97e"
},
{
"path": "skills/infrastructure-as-code-generator/assets/README.md",
"sha256": "4877e325c0235517847853aeafa8f16671404c143651030e1b9db5c572c3df88"
}
],
"dirSha256": "32521136fac2e0812635dea53b6a4cfd1a51d033b2f49140c69b01ae7977244a"
},
"security": {
"scannedAt": null,
"scannerVersion": null,
"flags": []
}
}

View File

@@ -0,0 +1,53 @@
---
name: generating-infrastructure-as-code
description: |
This skill enables Claude to generate Infrastructure as Code (IaC) configurations. It uses the infrastructure-as-code-generator plugin to create production-ready IaC for Terraform, CloudFormation, Pulumi, ARM Templates, and CDK. Use this skill when the user requests IaC configurations for cloud infrastructure, specifying the platform (e.g., Terraform, CloudFormation) and cloud provider (e.g., AWS, Azure, GCP), or when the user needs help automating infrastructure deployment. Trigger terms include: "generate IaC", "create Terraform", "CloudFormation template", "Pulumi program", "infrastructure code".
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
version: 1.0.0
---
## Overview
This skill empowers Claude to automate the creation of infrastructure code, streamlining the deployment and management of cloud resources. It supports multiple IaC platforms and cloud providers, ensuring flexibility and best practices.
## How It Works
1. **Receiving Request**: Claude receives a request for IaC generation, identifying the desired platform and cloud provider.
2. **Invoking Plugin**: Claude invokes the infrastructure-as-code-generator plugin with the user's specifications.
3. **Generating Code**: The plugin generates the requested IaC configuration based on the user's requirements.
4. **Presenting Code**: Claude presents the generated IaC code to the user for review and deployment.
## When to Use This Skill
This skill activates when you need to:
- Generate Terraform configurations for AWS, GCP, or Azure.
- Create CloudFormation templates for AWS infrastructure.
- Develop Pulumi programs for multi-cloud deployments.
## Examples
### Example 1: AWS ECS Fargate Infrastructure
User request: "Generate Terraform configuration for an AWS ECS Fargate cluster."
The skill will:
1. Invoke the infrastructure-as-code-generator plugin, specifying Terraform and AWS ECS Fargate.
2. Generate a Terraform configuration file defining the ECS cluster, task definition, and related resources.
### Example 2: Azure Resource Group Deployment
User request: "Create an ARM template for deploying an Azure Resource Group with a virtual network."
The skill will:
1. Invoke the infrastructure-as-code-generator plugin, specifying ARM template and Azure Resource Group.
2. Generate an ARM template defining the resource group and virtual network resources.
## Best Practices
- **Specificity**: Provide clear and specific requirements for the desired infrastructure.
- **Platform Selection**: Choose the appropriate IaC platform based on your cloud provider and organizational standards.
- **Review & Validation**: Always review and validate the generated IaC code before deploying it to production.
## Integration
This skill can be integrated with other Claude Code plugins for deployment automation, security scanning, and cost estimation, providing a comprehensive DevOps workflow. For example, it can be used with a deployment plugin to automatically deploy the generated infrastructure.

View File

@@ -0,0 +1,8 @@
# Assets
Bundled resources for infrastructure-as-code-generator skill
- [ ] terraform_templates/: Directory containing Terraform templates for various cloud resources (e.g., EC2 instances, S3 buckets, VPCs).
- [ ] cloudformation_templates/: Directory containing CloudFormation templates for various cloud resources.
- [ ] pulumi_examples/: Directory containing Pulumi examples for various cloud resources.
- [ ] iac_config_schema.json: JSON schema defining the structure of IaC configuration files.

View File

@@ -0,0 +1,201 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Infrastructure as Code Configuration",
"description": "Configuration schema for generating Infrastructure as Code.",
"type": "object",
"properties": {
"provider": {
"type": "string",
"enum": ["aws", "azure", "gcp", "kubernetes", "terraform", "cloudformation", "pulumi"],
"description": "Cloud provider or IaC tool to use.",
"_comment": "Supported providers include AWS, Azure, GCP, Kubernetes, Terraform, CloudFormation, and Pulumi."
},
"region": {
"type": "string",
"description": "Cloud region to deploy resources to.",
"default": "us-east-1",
"_comment": "Defaults to us-east-1 if not specified. Required for cloud providers."
},
"name": {
"type": "string",
"description": "Name of the infrastructure stack.",
"default": "my-infrastructure",
"_comment": "Used for naming resources and deployments."
},
"resource_group": {
"type": "string",
"description": "Resource group or project name.",
"_comment": "Relevant for Azure and GCP. Will be used to create the resource group if it doesn't exist (where possible)."
},
"resources": {
"type": "array",
"description": "List of resources to create.",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["ec2", "s3", "rds", "vpc", "subnet", "lambda", "container", "load_balancer", "firewall", "storage_account", "virtual_machine", "database", "service_account"],
"description": "Type of resource to create.",
"_comment": "Supported resource types vary depending on the provider."
},
"name": {
"type": "string",
"description": "Name of the resource."
},
"properties": {
"type": "object",
"description": "Resource-specific properties.",
"_comment": "These properties depend on the resource type and provider."
},
"dependencies": {
"type": "array",
"description": "List of resources this resource depends on.",
"items": {
"type": "string",
"description": "Name of a dependency."
},
"_comment": "Used to define resource creation order."
}
},
"required": ["type", "name"]
}
},
"outputs": {
"type": "array",
"description": "List of outputs to define.",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the output."
},
"value": {
"type": "string",
"description": "Expression for the output value (e.g., ARN of a resource)."
},
"description": {
"type": "string",
"description": "Description of the output."
}
},
"required": ["name", "value", "description"]
}
},
"variables": {
"type": "object",
"description": "Variables to use in the IaC.",
"additionalProperties": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["string", "number", "bool", "list", "map"],
"description": "Type of the variable."
},
"default": {
"type": ["string", "number", "boolean", "array", "object"],
"description": "Default value of the variable."
},
"description": {
"type": "string",
"description": "Description of the variable."
}
},
"required": ["type", "description"]
}
},
"tags": {
"type": "object",
"description": "Tags to apply to resources.",
"additionalProperties": {
"type": "string",
"description": "Tag value."
}
}
},
"required": ["provider", "resources"],
"example": {
"_comment": "Example AWS configuration for a simple EC2 instance.",
"provider": "aws",
"region": "us-west-2",
"name": "my-ec2-instance",
"tags": {
"Environment": "Production",
"Project": "WebApp"
},
"resources": [
{
"type": "vpc",
"name": "main_vpc",
"properties": {
"cidr_block": "10.0.0.0/16",
"enable_dns_hostnames": true,
"enable_dns_support": true
}
},
{
"type": "subnet",
"name": "public_subnet",
"properties": {
"vpc_id": "${main_vpc.id}",
"cidr_block": "10.0.1.0/24",
"availability_zone": "us-west-2a",
"map_public_ip_on_launch": true
},
"dependencies": ["main_vpc"]
},
{
"type": "ec2",
"name": "web_server",
"properties": {
"ami": "ami-0c55b33c5d5a45fb9",
"instance_type": "t2.micro",
"subnet_id": "${public_subnet.id}",
"key_name": "my-key",
"security_groups": ["${web_sg.id}"]
},
"dependencies": ["public_subnet", "web_sg"]
},
{
"type": "firewall",
"name": "web_sg",
"properties": {
"description": "Allow web traffic",
"ingress": [
{
"from_port": 80,
"to_port": 80,
"protocol": "tcp",
"cidr_blocks": ["0.0.0.0/0"]
},
{
"from_port": 443,
"to_port": 443,
"protocol": "tcp",
"cidr_blocks": ["0.0.0.0/0"]
}
],
"egress": [
{
"from_port": 0,
"to_port": 0,
"protocol": "-1",
"cidr_blocks": ["0.0.0.0/0"]
}
],
"vpc_id": "${main_vpc.id}"
},
"dependencies": ["main_vpc"]
}
],
"outputs": [
{
"name": "public_ip",
"value": "${web_server.public_ip}",
"description": "Public IP address of the web server."
}
]
}
}

View File

@@ -0,0 +1,9 @@
# References
Bundled resources for infrastructure-as-code-generator skill
- [ ] terraform_best_practices.md: Documentation on Terraform best practices, including modularity, security, and state management.
- [ ] cloudformation_best_practices.md: Documentation on CloudFormation best practices, including stack management, resource naming, and security groups.
- [ ] pulumi_best_practices.md: Documentation on Pulumi best practices, including componentization, configuration management, and testing.
- [ ] iac_security_standards.md: Documentation on security standards for IaC, including vulnerability scanning, access control, and compliance.
- [ ] api_documentation.md: API documentation for the IaC generation service, detailing available platforms, providers, and configuration options.

View File

@@ -0,0 +1,7 @@
# Scripts
Bundled resources for infrastructure-as-code-generator skill
- [ ] iac_generate.py: Script to generate IaC based on user input and platform selection. Handles API calls and template selection.
- [ ] validate_iac.py: Script to validate generated IaC against best practices and security standards. Supports Terraform, CloudFormation, Pulumi.
- [ ] deploy_iac.py: Script to deploy generated IaC to the specified cloud provider. Requires authentication and configuration details.