|
| 1 | +# Augment AI Prompt Templates for Terraform Provider Development |
| 2 | + |
| 3 | +## Template 1: New Resource Implementation |
| 4 | + |
| 5 | +### Context Setup |
| 6 | +``` |
| 7 | +Reference Documents: |
| 8 | +- TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md (comprehensive patterns and examples) |
| 9 | +- REDIS_CLOUD_TERRAFORM_SUMMARY.md (architecture overview and controller classification) |
| 10 | +
|
| 11 | +Target Controller: {CONTROLLER_NAME} (e.g., UsersController.java) |
| 12 | +Resource Name: rediscloud_{RESOURCE_NAME} (e.g., rediscloud_user) |
| 13 | +``` |
| 14 | + |
| 15 | +### Prompt Template |
| 16 | +``` |
| 17 | +Based on the TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md patterns, implement a complete Terraform resource for {CONTROLLER_NAME}. |
| 18 | +
|
| 19 | +Requirements: |
| 20 | +1. Follow the Step-by-Step Implementation Guide (Section 5) |
| 21 | +2. Use established schema patterns from existing resources |
| 22 | +3. Implement async operations using resource status polling (NOT TasksController) |
| 23 | +4. Follow the exact file structure and naming conventions |
| 24 | +
|
| 25 | +Generate the following files: |
| 26 | +- provider/resource_rediscloud_{RESOURCE_NAME}.go |
| 27 | +- docs/resources/rediscloud_{RESOURCE_NAME}.md |
| 28 | +- provider/resource_rediscloud_{RESOURCE_NAME}_test.go |
| 29 | +- Update to provider/provider.go for resource registration |
| 30 | +
|
| 31 | +Deliverables: |
| 32 | +[ ] Complete Go resource implementation with CRUD operations |
| 33 | +[ ] Proper schema definition with validation |
| 34 | +[ ] Wait functions for async operations (if needed) |
| 35 | +[ ] Comprehensive documentation following templates |
| 36 | +[ ] Acceptance tests with proper setup/teardown |
| 37 | +[ ] Provider registration update |
| 38 | +
|
| 39 | +Quality Checkpoints: |
| 40 | +- Schema follows TypeString/TypeInt/TypeBool patterns |
| 41 | +- Error handling uses diag.FromErr() |
| 42 | +- Documentation includes frontmatter, examples, and import instructions |
| 43 | +- Tests use acctest.RandomWithPrefix() for unique naming |
| 44 | +- No direct TasksController usage |
| 45 | +``` |
| 46 | + |
| 47 | +## Template 2: Resource Documentation Generation |
| 48 | + |
| 49 | +### Context Setup |
| 50 | +``` |
| 51 | +Reference: TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md Section 6 (Documentation Standards) |
| 52 | +Target Resource: rediscloud_{RESOURCE_NAME} |
| 53 | +Existing Implementation: provider/resource_rediscloud_{RESOURCE_NAME}.go |
| 54 | +``` |
| 55 | + |
| 56 | +### Prompt Template |
| 57 | +``` |
| 58 | +Generate complete Terraform resource documentation for rediscloud_{RESOURCE_NAME} following the exact template from TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md. |
| 59 | +
|
| 60 | +Input: Analyze the Go resource implementation to extract: |
| 61 | +- Schema fields and their types |
| 62 | +- Required vs optional parameters |
| 63 | +- Computed attributes |
| 64 | +- Nested blocks structure |
| 65 | +- Timeout configurations |
| 66 | +
|
| 67 | +Output: docs/resources/rediscloud_{RESOURCE_NAME}.md with: |
| 68 | +
|
| 69 | +Required Sections: |
| 70 | +1. Frontmatter (layout, page_title, description) |
| 71 | +2. Resource title and description |
| 72 | +3. Example Usage (realistic HCL examples) |
| 73 | +4. Argument Reference (all schema fields documented) |
| 74 | +5. Timeouts section (if custom timeouts supported) |
| 75 | +6. Attribute Reference (computed fields) |
| 76 | +7. Import section with syntax example |
| 77 | +
|
| 78 | +Quality Standards: |
| 79 | +- All schema fields documented with (Required/Optional) markers |
| 80 | +- ForceNew fields marked as "change forces recreation" |
| 81 | +- Nested blocks properly documented |
| 82 | +- Examples are syntactically correct HCL |
| 83 | +- Import syntax tested and accurate |
| 84 | +- Cross-references to related resources included |
| 85 | +``` |
| 86 | + |
| 87 | +## Template 3: Comprehensive Test Suite Generation |
| 88 | + |
| 89 | +### Context Setup |
| 90 | +``` |
| 91 | +Reference: TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md Section 8 (Testing Patterns) |
| 92 | +Target Resource: rediscloud_{RESOURCE_NAME} |
| 93 | +Implementation: provider/resource_rediscloud_{RESOURCE_NAME}.go |
| 94 | +``` |
| 95 | + |
| 96 | +### Prompt Template |
| 97 | +``` |
| 98 | +Generate comprehensive acceptance tests for rediscloud_{RESOURCE_NAME} following established testing patterns. |
| 99 | +
|
| 100 | +Create: provider/resource_rediscloud_{RESOURCE_NAME}_test.go |
| 101 | +
|
| 102 | +Test Cases to Include: |
| 103 | +1. TestAccResourceRedisCloud{ResourceName}_basic |
| 104 | +2. TestAccResourceRedisCloud{ResourceName}_update |
| 105 | +3. TestAccResourceRedisCloud{ResourceName}_import |
| 106 | +4. TestAccResourceRedisCloud{ResourceName}_disappears |
| 107 | +
|
| 108 | +Test Structure Requirements: |
| 109 | +- Use acctest.RandomWithPrefix("test-{resource}") for unique naming |
| 110 | +- Include proper PreCheck, ProviderFactories, CheckDestroy |
| 111 | +- Test all schema fields with TestCheckResourceAttr |
| 112 | +- Include update scenarios for mutable fields |
| 113 | +- Test import functionality |
| 114 | +- Handle resource cleanup properly |
| 115 | +
|
| 116 | +Quality Checkpoints: |
| 117 | +[ ] All required fields tested |
| 118 | +[ ] Update scenarios for mutable fields |
| 119 | +[ ] Import functionality verified |
| 120 | +[ ] Proper resource cleanup in CheckDestroy |
| 121 | +[ ] Realistic test configurations |
| 122 | +[ ] Error scenarios handled appropriately |
| 123 | +``` |
| 124 | + |
| 125 | +## Template 4: Code Review Against Established Patterns |
| 126 | + |
| 127 | +### Context Setup |
| 128 | +``` |
| 129 | +Reference: TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md (all sections) |
| 130 | +Review Target: [Generated or existing code files] |
| 131 | +``` |
| 132 | + |
| 133 | +### Prompt Template |
| 134 | +``` |
| 135 | +Review the following Terraform resource implementation against the established patterns in TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md: |
| 136 | +
|
| 137 | +[PASTE CODE HERE] |
| 138 | +
|
| 139 | +Review Criteria: |
| 140 | +
|
| 141 | +1. Architecture Compliance: |
| 142 | + - Follows resource-to-controller mapping patterns |
| 143 | + - Uses correct Go API service imports |
| 144 | + - Proper provider registration |
| 145 | +
|
| 146 | +2. Schema Design: |
| 147 | + - Consistent field types (TypeString, TypeInt, TypeBool) |
| 148 | + - Proper Required/Optional/Computed settings |
| 149 | + - Appropriate ForceNew settings |
| 150 | + - Clear descriptions for all fields |
| 151 | +
|
| 152 | +3. CRUD Operations: |
| 153 | + - Standard function signatures |
| 154 | + - Proper error handling with diag.FromErr() |
| 155 | + - Correct resource ID management |
| 156 | + - Appropriate mutex usage if needed |
| 157 | +
|
| 158 | +4. Async Operations: |
| 159 | + - Uses resource status polling (NOT TasksController) |
| 160 | + - Proper wait function implementation |
| 161 | + - Correct state transitions defined |
| 162 | + - Appropriate timeouts set |
| 163 | +
|
| 164 | +5. Documentation: |
| 165 | + - Follows template structure exactly |
| 166 | + - All schema fields documented |
| 167 | + - Realistic examples provided |
| 168 | + - Import syntax included |
| 169 | +
|
| 170 | +6. Testing: |
| 171 | + - Comprehensive test coverage |
| 172 | + - Proper test naming conventions |
| 173 | + - Realistic test configurations |
| 174 | + - Import testing included |
| 175 | +
|
| 176 | +Provide specific feedback on: |
| 177 | +- Pattern violations and how to fix them |
| 178 | +- Missing components |
| 179 | +- Quality improvements |
| 180 | +- Consistency issues |
| 181 | +``` |
| 182 | + |
| 183 | +## Template 5: sm-cloud-api Controller Analysis |
| 184 | + |
| 185 | +### Context Setup |
| 186 | +``` |
| 187 | +Reference: TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md Section 4 (Available Controllers) |
| 188 | +Target: New controller in sm-cloud-api for potential Terraform resource |
| 189 | +``` |
| 190 | + |
| 191 | +### Prompt Template |
| 192 | +``` |
| 193 | +Analyze the {CONTROLLER_NAME} from sm-cloud-api to determine its suitability for Terraform resource implementation. |
| 194 | +
|
| 195 | +Analysis Framework: |
| 196 | +
|
| 197 | +1. Controller Classification: |
| 198 | + - Is this a user-facing resource or internal utility? |
| 199 | + - Does it manage stateful infrastructure components? |
| 200 | + - Is it similar to TasksController (internal-only) or SubscriptionsController (resource-worthy)? |
| 201 | +
|
| 202 | +2. API Endpoint Analysis: |
| 203 | + - What CRUD operations are available? |
| 204 | + - What is the resource lifecycle (create → active → delete)? |
| 205 | + - Are there async operations that require wait functions? |
| 206 | +
|
| 207 | +3. Terraform Resource Potential: |
| 208 | + - What would the resource name be? (rediscloud_{name}) |
| 209 | + - What schema fields would be needed? |
| 210 | + - How would it integrate with existing resources? |
| 211 | + - What would be the user value proposition? |
| 212 | +
|
| 213 | +4. Implementation Complexity: |
| 214 | + - Does rediscloud-go-api support this controller? |
| 215 | + - Are there dependencies on other resources? |
| 216 | + - What async operation patterns would be needed? |
| 217 | +
|
| 218 | +5. Priority Assessment: |
| 219 | + - High/Medium/Low priority for implementation |
| 220 | + - Business value and user demand |
| 221 | + - Technical complexity vs. benefit ratio |
| 222 | +
|
| 223 | +Output Format: |
| 224 | +- Classification: [User-Facing Resource | Internal Utility | Helper Controller] |
| 225 | +- Recommended Action: [Implement | Skip | Investigate Further] |
| 226 | +- Priority: [High | Medium | Low] |
| 227 | +- Estimated Effort: [Low | Medium | High] |
| 228 | +- Dependencies: [List any dependent resources or services] |
| 229 | +- Notes: [Special considerations or concerns] |
| 230 | +``` |
| 231 | + |
| 232 | +## Template 6: TerraForge AI Hackathon Workflow |
| 233 | + |
| 234 | +### Context Setup |
| 235 | +``` |
| 236 | +Project: TerraForge AI - Intelligent Terraform Resource Generator |
| 237 | +References: |
| 238 | +- TERRAFORM_PROVIDER_DEVELOPMENT_GUIDE.md (complete patterns) |
| 239 | +- REDIS_CLOUD_TERRAFORM_SUMMARY.md (controller priorities) |
| 240 | +Target Controllers: [List 3 controllers for hackathon implementation] |
| 241 | +``` |
| 242 | + |
| 243 | +### Prompt Template |
| 244 | +``` |
| 245 | +Execute TerraForge AI workflow to automatically generate production-ready Terraform resources. |
| 246 | +
|
| 247 | +Phase 1: Analysis & Planning |
| 248 | +1. Analyze target controllers: {CONTROLLER_LIST} |
| 249 | +2. Extract patterns from existing implementations |
| 250 | +3. Identify schema requirements for each resource |
| 251 | +4. Plan async operation handling strategies |
| 252 | +
|
| 253 | +Phase 2: Code Generation |
| 254 | +For each controller, generate: |
| 255 | +1. Complete Go resource implementation |
| 256 | +2. Comprehensive documentation |
| 257 | +3. Full test suite |
| 258 | +4. Provider registration updates |
| 259 | +
|
| 260 | +Phase 3: Quality Assurance |
| 261 | +1. Validate against established patterns |
| 262 | +2. Ensure async operations use resource polling (NOT tasks) |
| 263 | +3. Verify documentation completeness |
| 264 | +4. Confirm test coverage |
| 265 | +
|
| 266 | +Phase 4: Integration |
| 267 | +1. Update provider registration |
| 268 | +2. Ensure cross-references work |
| 269 | +3. Validate import functionality |
| 270 | +4. Test end-to-end workflows |
| 271 | +
|
| 272 | +Success Metrics: |
| 273 | +- 3 complete resources implemented |
| 274 | +- 100% pattern compliance |
| 275 | +- Complete documentation and tests |
| 276 | +- <30 minutes per resource (vs 6 hours manual) |
| 277 | +
|
| 278 | +Deliverables: |
| 279 | +[ ] provider/resource_rediscloud_{resource1}.go + docs + tests |
| 280 | +[ ] provider/resource_rediscloud_{resource2}.go + docs + tests |
| 281 | +[ ] provider/resource_rediscloud_{resource3}.go + docs + tests |
| 282 | +[ ] Updated provider/provider.go |
| 283 | +[ ] Workflow documentation for future use |
| 284 | +[ ] Metrics on time savings and quality improvements |
| 285 | +
|
| 286 | +Quality Gates: |
| 287 | +- All generated code passes linting |
| 288 | +- Documentation follows exact templates |
| 289 | +- Tests achieve 100% coverage |
| 290 | +- No TasksController direct usage |
| 291 | +- Import functionality works correctly |
| 292 | +``` |
| 293 | + |
| 294 | +--- |
| 295 | + |
| 296 | +## Usage Instructions |
| 297 | + |
| 298 | +1. **Choose the appropriate template** based on your development task |
| 299 | +2. **Fill in the placeholders** (marked with {PLACEHOLDER}) with specific values |
| 300 | +3. **Reference the context documents** to ensure AI has proper background |
| 301 | +4. **Use the quality checkpoints** to validate outputs |
| 302 | +5. **Iterate and refine** based on results |
| 303 | + |
| 304 | +These templates ensure consistent, high-quality Terraform resource development while leveraging AI tools effectively. |
0 commit comments