generating-infrastructure-as-code
Use when generating infrastructure as code configurations. Trigger with phrases like "create Terraform config", "generate CloudFormation template", "write Pulumi code", or "IaC for AWS/GCP/Azure". Produces production-ready code for Terraform, CloudFormation, Pulumi, ARM templates, and CDK across multiple cloud providers.
- License 许可
- MIT
- 最近更新
- 2025-12-18
- Stars
- ★ 29
- Forks
- 9
01 前言 Front Matter
- name
- generating-infrastructure-as-code
- license
- MIT
- version
- 1.0.0
- description
- Use when generating infrastructure as code configurations. Trigger with phrases like "create Terraform config", "generate CloudFormation template", "write Pulumi code", or "IaC for AWS/GCP/Azure". Produces production-ready code for Terraform, CloudFormation, Pulumi, ARM templates, and CDK across multiple cloud providers.
- allowed-tools
- [ "Read", "Write", "Edit", "Grep", "Glob", "Bash(terraform:*)", "Bash(aws:*)", "Bash(gcloud:*)", "Bash(az:*)" ]
02 资源文件 5
- 资产文件assets/iac_config_schema.json6.1 KB
- 资产文件assets/README.md501 B
- 参考文档references/README.md792 B
- 脚本scripts/iac_generate.py3.7 KB
- 脚本scripts/README.md488 B
03 SKILL.md 正文
Prerequisites
Before using this skill, ensure:
- Target cloud provider CLI is installed (aws-cli, gcloud, az)
- IaC tool is installed (Terraform, Pulumi, AWS CDK)
- Cloud credentials are configured locally
- Understanding of target infrastructure architecture
- Version control system for IaC storage
Instructions
- Identify Platform: Determine IaC tool (Terraform, CloudFormation, Pulumi, ARM, CDK)
- Define Resources: Specify cloud resources needed (compute, network, storage, database)
- Establish Structure: Create modular file structure for maintainability
- Generate Code: Write IaC configurations with proper syntax and formatting
- Add Variables: Define input variables for environment-specific values
- Configure Outputs: Specify outputs for resource references and integrations
- Implement State: Set up remote state storage for team collaboration
- Document Usage: Add README with deployment instructions and prerequisites
Output
Generates infrastructure as code files:
Terraform Example:
# {baseDir}/terraform/main.tf
terraform {
required_version = ">= 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
resource "aws_vpc" "main" {
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
tags = {
Name = "${var.project}-vpc"
Environment = var.environment
}
}
CloudFormation Example:
# {baseDir}/cloudformation/template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: Production VPC infrastructure
Parameters:
VpcCidr:
Type: String
Default: 10.0.0.0/16
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCidr
EnableDnsHostnames: true
Pulumi Example:
// {baseDir}/pulumi/index.ts
import * as aws from "@pulumi/aws";
const vpc = new aws.ec2.Vpc("main", {
cidrBlock: "10.0.0.0/16",
enableDnsHostnames: true,
tags: {
Name: "production-vpc"
}
});
export const vpcId = vpc.id;
Error Handling
Common issues and solutions:
Syntax Errors
- Error: "Invalid resource syntax in configuration"
- Solution: Validate syntax with
terraform validateor respective tool linter
Provider Authentication
- Error: "Unable to authenticate with cloud provider"
- Solution: Configure credentials via environment variables or CLI login
Resource Conflicts
- Error: "Resource already exists"
- Solution: Import existing resources or use data sources instead of creating new ones
State Lock Issues
- Error: "Error acquiring state lock"
- Solution: Ensure no other process is running, or force unlock if safe
Dependency Errors
- Error: "Resource depends on resource that does not exist"
- Solution: Check resource references and ensure proper dependency ordering
Resources
- Terraform documentation: https://www.terraform.io/docs/
- AWS CloudFormation guide: https://docs.aws.amazon.com/cloudformation/
- Pulumi documentation: https://www.pulumi.com/docs/
- Azure ARM templates: https://docs.microsoft.com/azure/azure-resource-manager/
- IaC best practices guide in {baseDir}/docs/iac-standards.md
04 同仓库更多 Skills
testing-visual-regression
Detect visual changes in UI components using screenshot comparison. Use when detecting unintended UI changes or pixel differences. Trigger with phrases like "test visual changes", "compare screenshots", or "detect UI regressions".
generating-unit-tests
Automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions. Use when creating test coverage for functions, classes, or modules. Trigger with phrases like "generate unit tests", "create tests for", or "add test coverage".
generating-test-reports
Generate comprehensive test reports with metrics, coverage, and visualizations. Use when performing specialized testing. Trigger with phrases like "generate test report", "create test documentation", or "show test metrics".
orchestrating-test-execution
Coordinate parallel test execution across multiple environments and frameworks. Use when performing specialized testing. Trigger with phrases like "orchestrate tests", "run parallel tests", or "coordinate test execution".
managing-test-environments
Provision and manage isolated test environments with configuration and data. Use when performing specialized testing. Trigger with phrases like "manage test environment", "provision test env", or "setup test infrastructure".
generating-test-doubles
Generate mocks, stubs, spies, and fakes for dependency isolation. Use when creating mocks, stubs, or test isolation fixtures. Trigger with phrases like "generate mocks", "create test doubles", or "setup stubs".