@opengeni/runtime 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2PO56VAL.js +3478 -0
- package/dist/chunk-2PO56VAL.js.map +1 -0
- package/dist/index.d.ts +912 -0
- package/dist/index.js +3663 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox/index.d.ts +1738 -0
- package/dist/sandbox/index.js +187 -0
- package/dist/sandbox/index.js.map +1 -0
- package/package.json +49 -0
- package/src/bundled_hashicorp_terraform_skills/LICENSE +373 -0
- package/src/bundled_hashicorp_terraform_skills/README.md +18 -0
- package/src/bundled_hashicorp_terraform_skills/UPSTREAM_GIT_SHA +1 -0
- package/src/bundled_hashicorp_terraform_skills/azure-verified-modules/SKILL.md +613 -0
- package/src/bundled_hashicorp_terraform_skills/checkov/SKILL.md +43 -0
- package/src/bundled_hashicorp_terraform_skills/refactor-module/SKILL.md +538 -0
- package/src/bundled_hashicorp_terraform_skills/social-media-marketing/SKILL.md +35 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-search-import/SKILL.md +372 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-search-import/references/MANUAL-IMPORT.md +113 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-search-import/scripts/list_resources.sh +38 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-stacks/SKILL.md +480 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/api-monitoring.md +543 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/component-blocks.md +476 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/deployment-blocks.md +391 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/examples.md +1529 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/linked-stacks.md +187 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/troubleshooting.md +671 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-style-guide/SKILL.md +353 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-test/SKILL.md +451 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-test/references/CI_CD.md +80 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-test/references/EXAMPLES.md +314 -0
- package/src/bundled_hashicorp_terraform_skills/terraform-test/references/MOCK_PROVIDERS.md +171 -0
- package/src/codex-tool-search.ts +267 -0
- package/src/context-compaction.ts +538 -0
- package/src/history-sanitizer.ts +719 -0
- package/src/index.ts +3299 -0
- package/src/sandbox/capabilities.ts +69 -0
- package/src/sandbox/channel-a.ts +1031 -0
- package/src/sandbox/display-stack.ts +231 -0
- package/src/sandbox/errors.ts +34 -0
- package/src/sandbox/index.ts +832 -0
- package/src/sandbox/providers/blaxel.ts +35 -0
- package/src/sandbox/providers/cloudflare.ts +24 -0
- package/src/sandbox/providers/daytona.ts +34 -0
- package/src/sandbox/providers/docker.ts +17 -0
- package/src/sandbox/providers/e2b.ts +36 -0
- package/src/sandbox/providers/index.ts +107 -0
- package/src/sandbox/providers/local.ts +13 -0
- package/src/sandbox/providers/modal.ts +55 -0
- package/src/sandbox/providers/none.ts +13 -0
- package/src/sandbox/providers/runloop.ts +32 -0
- package/src/sandbox/providers/selfhosted.ts +96 -0
- package/src/sandbox/providers/types.ts +38 -0
- package/src/sandbox/providers/vercel.ts +29 -0
- package/src/sandbox/recording.ts +286 -0
- package/src/sandbox/routing/backend-resolver.ts +189 -0
- package/src/sandbox/routing/routing-session.ts +455 -0
- package/src/sandbox/select.ts +371 -0
- package/src/sandbox/selfhosted/capabilities.ts +255 -0
- package/src/sandbox/selfhosted/control-rpc.ts +351 -0
- package/src/sandbox/selfhosted/session.ts +930 -0
- package/src/sandbox/selfhosted/testing.ts +230 -0
- package/src/sandbox/stream-port.ts +185 -0
- package/src/sandbox/stream-token.ts +90 -0
- package/src/sandbox/terminal-server.ts +203 -0
- package/src/sandbox-computer.ts +835 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: refactor-module
|
|
3
|
+
description: Transform monolithic Terraform configurations into reusable, maintainable modules following HashiCorp's module design principles and community best practices.
|
|
4
|
+
metadata:
|
|
5
|
+
copyright: Copyright IBM Corp. 2026
|
|
6
|
+
version: "0.0.1"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Skill: Refactor Module
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
This skill guides AI agents in transforming monolithic Terraform configurations into reusable, maintainable modules following HashiCorp's module design principles and community best practices.
|
|
13
|
+
|
|
14
|
+
## Capability Statement
|
|
15
|
+
The agent will analyze existing Terraform code and systematically refactor it into well-structured modules with:
|
|
16
|
+
- Clear interface contracts (variables and outputs)
|
|
17
|
+
- Proper encapsulation and abstraction
|
|
18
|
+
- Versioning and documentation
|
|
19
|
+
- Testing frameworks
|
|
20
|
+
- Migration path for existing state
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
- Existing Terraform configuration to refactor
|
|
24
|
+
- Understanding of resource dependencies
|
|
25
|
+
- Access to current state file (for migration planning)
|
|
26
|
+
- Knowledge of module registry patterns
|
|
27
|
+
|
|
28
|
+
## Input Parameters
|
|
29
|
+
|
|
30
|
+
| Parameter | Type | Required | Description |
|
|
31
|
+
|-----------|------|----------|-------------|
|
|
32
|
+
| `source_directory` | string | Yes | Path to existing Terraform configuration |
|
|
33
|
+
| `module_name` | string | Yes | Name for the new module |
|
|
34
|
+
| `abstraction_level` | string | No | "simple", "intermediate", "advanced" (default: intermediate) |
|
|
35
|
+
| `preserve_state` | boolean | Yes | Whether to maintain state compatibility |
|
|
36
|
+
| `target_registry` | string | No | Target module registry (local, private, public) |
|
|
37
|
+
|
|
38
|
+
## Execution Steps
|
|
39
|
+
|
|
40
|
+
### 1. Analysis Phase
|
|
41
|
+
```markdown
|
|
42
|
+
**Identify Refactoring Candidates**
|
|
43
|
+
- Group resources by logical function
|
|
44
|
+
- Identify repeated patterns
|
|
45
|
+
- Map resource dependencies
|
|
46
|
+
- Detect configuration coupling
|
|
47
|
+
- Analyze variable usage patterns
|
|
48
|
+
|
|
49
|
+
**Complexity Assessment**
|
|
50
|
+
- Count resource relationships
|
|
51
|
+
- Measure variable propagation depth
|
|
52
|
+
- Identify cross-resource references
|
|
53
|
+
- Evaluate state migration complexity
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 2. Module Design
|
|
57
|
+
|
|
58
|
+
#### Interface Design
|
|
59
|
+
```hcl
|
|
60
|
+
# Define clear input contract
|
|
61
|
+
variable "network_config" {
|
|
62
|
+
description = "Network configuration parameters"
|
|
63
|
+
type = object({
|
|
64
|
+
cidr_block = string
|
|
65
|
+
availability_zones = list(string)
|
|
66
|
+
enable_nat = bool
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
validation {
|
|
70
|
+
condition = can(cidrhost(var.network_config.cidr_block, 0))
|
|
71
|
+
error_message = "CIDR block must be valid IPv4 CIDR."
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# Define output contract
|
|
76
|
+
output "vpc_id" {
|
|
77
|
+
description = "ID of the created VPC"
|
|
78
|
+
value = aws_vpc.main.id
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
output "private_subnet_ids" {
|
|
82
|
+
description = "List of private subnet IDs"
|
|
83
|
+
value = { for k, v in aws_subnet.private : k => v.id }
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Encapsulation Strategy
|
|
88
|
+
```markdown
|
|
89
|
+
**What to Include in Module:**
|
|
90
|
+
- Tightly coupled resources (VPC + subnets)
|
|
91
|
+
- Resources with shared lifecycle
|
|
92
|
+
- Configuration with clear boundaries
|
|
93
|
+
|
|
94
|
+
**What to Keep Separate:**
|
|
95
|
+
- Cross-cutting concerns (monitoring, tagging)
|
|
96
|
+
- Resources with different lifecycles
|
|
97
|
+
- Provider-specific configurations
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 3. Code Transformation
|
|
101
|
+
|
|
102
|
+
#### Before: Monolithic Configuration
|
|
103
|
+
```hcl
|
|
104
|
+
# main.tf (monolithic)
|
|
105
|
+
resource "aws_vpc" "main" {
|
|
106
|
+
cidr_block = "10.0.0.0/16"
|
|
107
|
+
enable_dns_hostnames = true
|
|
108
|
+
|
|
109
|
+
tags = {
|
|
110
|
+
Name = "production-vpc"
|
|
111
|
+
Environment = "prod"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
resource "aws_subnet" "public_1" {
|
|
116
|
+
vpc_id = aws_vpc.main.id
|
|
117
|
+
cidr_block = "10.0.1.0/24"
|
|
118
|
+
availability_zone = "us-east-1a"
|
|
119
|
+
|
|
120
|
+
tags = {
|
|
121
|
+
Name = "public-subnet-1"
|
|
122
|
+
Type = "public"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
resource "aws_subnet" "public_2" {
|
|
127
|
+
vpc_id = aws_vpc.main.id
|
|
128
|
+
cidr_block = "10.0.2.0/24"
|
|
129
|
+
availability_zone = "us-east-1b"
|
|
130
|
+
|
|
131
|
+
tags = {
|
|
132
|
+
Name = "public-subnet-2"
|
|
133
|
+
Type = "public"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
resource "aws_internet_gateway" "main" {
|
|
138
|
+
vpc_id = aws_vpc.main.id
|
|
139
|
+
|
|
140
|
+
tags = {
|
|
141
|
+
Name = "production-igw"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
# ... more repetitive subnet and routing resources
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### After: Modular Structure
|
|
149
|
+
```hcl
|
|
150
|
+
# modules/vpc/main.tf
|
|
151
|
+
locals {
|
|
152
|
+
subnet_count = length(var.availability_zones)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
resource "aws_vpc" "main" {
|
|
156
|
+
cidr_block = var.cidr_block
|
|
157
|
+
enable_dns_hostnames = var.enable_dns_hostnames
|
|
158
|
+
enable_dns_support = var.enable_dns_support
|
|
159
|
+
|
|
160
|
+
tags = merge(
|
|
161
|
+
var.tags,
|
|
162
|
+
{
|
|
163
|
+
Name = var.name
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
resource "aws_subnet" "public" {
|
|
169
|
+
for_each = var.create_public_subnets ? toset(var.availability_zones) : []
|
|
170
|
+
|
|
171
|
+
vpc_id = aws_vpc.main.id
|
|
172
|
+
cidr_block = cidrsubnet(var.cidr_block, 8, index(var.availability_zones, each.value))
|
|
173
|
+
availability_zone = each.value
|
|
174
|
+
map_public_ip_on_launch = true
|
|
175
|
+
|
|
176
|
+
tags = merge(
|
|
177
|
+
var.tags,
|
|
178
|
+
{
|
|
179
|
+
Name = "${var.name}-public-${each.value}"
|
|
180
|
+
Type = "public"
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
resource "aws_internet_gateway" "main" {
|
|
186
|
+
count = var.create_public_subnets ? 1 : 0
|
|
187
|
+
vpc_id = aws_vpc.main.id
|
|
188
|
+
|
|
189
|
+
tags = merge(
|
|
190
|
+
var.tags,
|
|
191
|
+
{
|
|
192
|
+
Name = "${var.name}-igw"
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
# modules/vpc/variables.tf
|
|
198
|
+
variable "name" {
|
|
199
|
+
description = "Name prefix for all resources"
|
|
200
|
+
type = string
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
variable "cidr_block" {
|
|
204
|
+
description = "CIDR block for the VPC"
|
|
205
|
+
type = string
|
|
206
|
+
|
|
207
|
+
validation {
|
|
208
|
+
condition = can(cidrhost(var.cidr_block, 0))
|
|
209
|
+
error_message = "Must be a valid IPv4 CIDR block."
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
variable "availability_zones" {
|
|
214
|
+
description = "List of availability zones"
|
|
215
|
+
type = list(string)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
variable "create_public_subnets" {
|
|
219
|
+
description = "Whether to create public subnets"
|
|
220
|
+
type = bool
|
|
221
|
+
default = true
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
variable "enable_dns_hostnames" {
|
|
225
|
+
description = "Enable DNS hostnames in the VPC"
|
|
226
|
+
type = bool
|
|
227
|
+
default = true
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
variable "enable_dns_support" {
|
|
231
|
+
description = "Enable DNS support in the VPC"
|
|
232
|
+
type = bool
|
|
233
|
+
default = true
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
variable "tags" {
|
|
237
|
+
description = "Tags to apply to all resources"
|
|
238
|
+
type = map(string)
|
|
239
|
+
default = {}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
# modules/vpc/outputs.tf
|
|
243
|
+
output "vpc_id" {
|
|
244
|
+
description = "ID of the VPC"
|
|
245
|
+
value = aws_vpc.main.id
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
output "vpc_cidr_block" {
|
|
249
|
+
description = "CIDR block of the VPC"
|
|
250
|
+
value = aws_vpc.main.cidr_block
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
output "public_subnet_ids" {
|
|
254
|
+
description = "Map of availability zones to public subnet IDs"
|
|
255
|
+
value = { for k, v in aws_subnet.public : k => v.id }
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
output "internet_gateway_id" {
|
|
259
|
+
description = "ID of the internet gateway"
|
|
260
|
+
value = try(aws_internet_gateway.main[0].id, null)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
# Root configuration using module
|
|
264
|
+
module "vpc" {
|
|
265
|
+
source = "./modules/vpc"
|
|
266
|
+
|
|
267
|
+
name = "production"
|
|
268
|
+
cidr_block = "10.0.0.0/16"
|
|
269
|
+
availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c"]
|
|
270
|
+
|
|
271
|
+
tags = {
|
|
272
|
+
Environment = "production"
|
|
273
|
+
ManagedBy = "Terraform"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### 4. State Migration
|
|
279
|
+
|
|
280
|
+
#### Generate Migration Plan
|
|
281
|
+
```hcl
|
|
282
|
+
# migration.tf
|
|
283
|
+
# Use moved blocks for state refactoring (Terraform 1.1+)
|
|
284
|
+
|
|
285
|
+
moved {
|
|
286
|
+
from = aws_vpc.main
|
|
287
|
+
to = module.vpc.aws_vpc.main
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
moved {
|
|
291
|
+
from = aws_subnet.public_1
|
|
292
|
+
to = module.vpc.aws_subnet.public["us-east-1a"]
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
moved {
|
|
296
|
+
from = aws_subnet.public_2
|
|
297
|
+
to = module.vpc.aws_subnet.public["us-east-1b"]
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
moved {
|
|
301
|
+
from = aws_internet_gateway.main
|
|
302
|
+
to = module.vpc.aws_internet_gateway.main[0]
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
#### Manual State Migration (Pre-1.1)
|
|
307
|
+
```bash
|
|
308
|
+
# Generate state migration commands
|
|
309
|
+
terraform state mv aws_vpc.main module.vpc.aws_vpc.main
|
|
310
|
+
terraform state mv aws_subnet.public_1 'module.vpc.aws_subnet.public["us-east-1a"]'
|
|
311
|
+
terraform state mv aws_subnet.public_2 'module.vpc.aws_subnet.public["us-east-1b"]'
|
|
312
|
+
terraform state mv aws_internet_gateway.main 'module.vpc.aws_internet_gateway.main[0]'
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### 5. Module Documentation
|
|
316
|
+
|
|
317
|
+
```markdown
|
|
318
|
+
# VPC Module
|
|
319
|
+
|
|
320
|
+
## Overview
|
|
321
|
+
Creates a VPC with configurable public and private subnets across multiple availability zones.
|
|
322
|
+
|
|
323
|
+
## Features
|
|
324
|
+
- Multi-AZ subnet deployment
|
|
325
|
+
- Optional NAT gateway configuration
|
|
326
|
+
- VPC Flow Logs integration
|
|
327
|
+
- Customizable CIDR allocation
|
|
328
|
+
|
|
329
|
+
## Usage
|
|
330
|
+
|
|
331
|
+
\`\`\`hcl
|
|
332
|
+
module "vpc" {
|
|
333
|
+
source = "./modules/vpc"
|
|
334
|
+
|
|
335
|
+
name = "my-vpc"
|
|
336
|
+
cidr_block = "10.0.0.0/16"
|
|
337
|
+
availability_zones = ["us-east-1a", "us-east-1b"]
|
|
338
|
+
|
|
339
|
+
create_public_subnets = true
|
|
340
|
+
create_private_subnets = true
|
|
341
|
+
enable_nat_gateway = true
|
|
342
|
+
|
|
343
|
+
tags = {
|
|
344
|
+
Environment = "production"
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
\`\`\`
|
|
348
|
+
|
|
349
|
+
## Requirements
|
|
350
|
+
|
|
351
|
+
| Name | Version |
|
|
352
|
+
|------|---------|
|
|
353
|
+
| terraform | >= 1.5.0 |
|
|
354
|
+
| aws | ~> 5.0 |
|
|
355
|
+
|
|
356
|
+
## Inputs
|
|
357
|
+
|
|
358
|
+
| Name | Description | Type | Default | Required |
|
|
359
|
+
|------|-------------|------|---------|----------|
|
|
360
|
+
| name | Name prefix for resources | `string` | n/a | yes |
|
|
361
|
+
| cidr_block | VPC CIDR block | `string` | n/a | yes |
|
|
362
|
+
| availability_zones | List of AZs | `list(string)` | n/a | yes |
|
|
363
|
+
|
|
364
|
+
## Outputs
|
|
365
|
+
|
|
366
|
+
| Name | Description |
|
|
367
|
+
|------|-------------|
|
|
368
|
+
| vpc_id | VPC identifier |
|
|
369
|
+
| public_subnet_ids | Map of public subnet IDs |
|
|
370
|
+
| private_subnet_ids | Map of private subnet IDs |
|
|
371
|
+
|
|
372
|
+
## Examples
|
|
373
|
+
|
|
374
|
+
See [examples/](./examples/) directory for complete usage examples.
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### 6. Testing
|
|
378
|
+
|
|
379
|
+
Use skill terraform-test
|
|
380
|
+
|
|
381
|
+
**Test File**: A `.tftest.hcl` or `.tftest.json` file containing test configuration and run blocks that validate your Terraform configuration.
|
|
382
|
+
|
|
383
|
+
**Test Block**: Optional configuration block that defines test-wide settings (available since Terraform 1.6.0).
|
|
384
|
+
|
|
385
|
+
**Run Block**: Defines a single test scenario with optional variables, provider configurations, and assertions. Each test file requires at least one run block.
|
|
386
|
+
|
|
387
|
+
**Assert Block**: Contains conditions that must evaluate to true for the test to pass. Failed assertions cause the test to fail.
|
|
388
|
+
|
|
389
|
+
**Mock Provider**: Simulates provider behavior without creating real infrastructure (available since Terraform 1.7.0).
|
|
390
|
+
|
|
391
|
+
**Test Modes**: Tests run in apply mode (default, creates real infrastructure) or plan mode (validates logic without creating resources).
|
|
392
|
+
|
|
393
|
+
#### File Structure
|
|
394
|
+
|
|
395
|
+
Terraform test files use the `.tftest.hcl` or `.tftest.json` extension and are typically organized in a `tests/` directory. Use clear naming conventions to distinguish between unit tests (plan mode) and integration tests (apply mode):
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
my-module/
|
|
399
|
+
├── main.tf
|
|
400
|
+
├── variables.tf
|
|
401
|
+
├── outputs.tf
|
|
402
|
+
└── tests/
|
|
403
|
+
├── unit_test.tftest.hcl # Unit test (plan mode)
|
|
404
|
+
└── integration_test.tftest.hcl # Integration test (apply mode - creates real resources)
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Refactoring Patterns
|
|
408
|
+
|
|
409
|
+
### Pattern 1: Resource Grouping
|
|
410
|
+
Extract related resources into cohesive modules:
|
|
411
|
+
- Networking (VPC, Subnets, Route Tables)
|
|
412
|
+
- Compute (ASG, Launch Templates, Load Balancers)
|
|
413
|
+
- Data (RDS, ElastiCache, S3)
|
|
414
|
+
|
|
415
|
+
### Pattern 2: Configuration Layering
|
|
416
|
+
```hcl
|
|
417
|
+
# Base module with defaults
|
|
418
|
+
module "vpc_base" {
|
|
419
|
+
source = "./modules/vpc-base"
|
|
420
|
+
# Minimal required inputs
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
# Environment-specific wrapper
|
|
424
|
+
module "vpc_prod" {
|
|
425
|
+
source = "./modules/vpc-production"
|
|
426
|
+
# Inherits from base, adds prod-specific config
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Pattern 3: Composition
|
|
431
|
+
```hcl
|
|
432
|
+
# Small, focused modules
|
|
433
|
+
module "vpc" {
|
|
434
|
+
source = "./modules/vpc"
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
module "security_groups" {
|
|
438
|
+
source = "./modules/security-groups"
|
|
439
|
+
vpc_id = module.vpc.vpc_id
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
module "application" {
|
|
443
|
+
source = "./modules/application"
|
|
444
|
+
vpc_id = module.vpc.vpc_id
|
|
445
|
+
subnet_ids = module.vpc.private_subnet_ids
|
|
446
|
+
sg_ids = module.security_groups.app_sg_ids
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## Common Pitfalls
|
|
451
|
+
|
|
452
|
+
### 1. Over-Abstraction
|
|
453
|
+
```hcl
|
|
454
|
+
# ❌ Don't create overly generic modules
|
|
455
|
+
variable "resources" {
|
|
456
|
+
type = map(map(any)) # Too flexible, hard to validate
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
# ✅ Do use specific, typed interfaces
|
|
460
|
+
variable "database_config" {
|
|
461
|
+
type = object({
|
|
462
|
+
engine = string
|
|
463
|
+
instance_class = string
|
|
464
|
+
})
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### 2. Tight Coupling
|
|
469
|
+
```hcl
|
|
470
|
+
# ❌ Don't couple modules through direct references
|
|
471
|
+
# module A
|
|
472
|
+
output "instance_id" { value = aws_instance.app.id }
|
|
473
|
+
|
|
474
|
+
# module B (in same config)
|
|
475
|
+
resource "aws_eip" "app" {
|
|
476
|
+
instance = module.a.instance_id # Tight coupling
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
# ✅ Do pass dependencies through root module
|
|
480
|
+
module "compute" {
|
|
481
|
+
source = "./modules/compute"
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
resource "aws_eip" "app" {
|
|
485
|
+
instance = module.compute.instance_id
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### 3. State Migration Errors
|
|
490
|
+
Always test migration in non-production first:
|
|
491
|
+
```bash
|
|
492
|
+
# Create plan to verify no changes after migration
|
|
493
|
+
terraform plan -out=migration.tfplan
|
|
494
|
+
|
|
495
|
+
# Review carefully
|
|
496
|
+
terraform show migration.tfplan
|
|
497
|
+
|
|
498
|
+
# Apply only if plan shows no changes
|
|
499
|
+
terraform apply migration.tfplan
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
## Version Control Strategy
|
|
503
|
+
|
|
504
|
+
```hcl
|
|
505
|
+
# Use semantic versioning for modules
|
|
506
|
+
module "vpc" {
|
|
507
|
+
source = "git::https://github.com/org/terraform-modules.git//vpc?ref=v1.2.0"
|
|
508
|
+
version = "~> 1.2"
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
# Pin to specific versions in production
|
|
512
|
+
# Use version ranges in development
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
## Success Criteria
|
|
516
|
+
|
|
517
|
+
- [ ] Module has single, well-defined responsibility
|
|
518
|
+
- [ ] All variables have descriptions and types
|
|
519
|
+
- [ ] Validation rules prevent invalid configurations
|
|
520
|
+
- [ ] Outputs provide sufficient information for consumers
|
|
521
|
+
- [ ] Documentation includes usage examples
|
|
522
|
+
- [ ] Tests verify module behavior
|
|
523
|
+
- [ ] State migration completed without resource recreation
|
|
524
|
+
- [ ] No plan differences after refactoring
|
|
525
|
+
|
|
526
|
+
## Related Skills
|
|
527
|
+
- [Terraform code generation](https://raw.githubusercontent.com/hashicorp/agent-skills/refs/heads/main/terraform/code-generation/skills/terraform-style-guide/SKILL.md) - Style guide for the new Terraform Module
|
|
528
|
+
- [Azure Verified Modules](https://raw.githubusercontent.com/hashicorp/agent-skills/refs/heads/main/terraform/code-generation/skills/azure-verified-modules/SKILL.md) - Recommended module specifications for Azure
|
|
529
|
+
|
|
530
|
+
## Resources
|
|
531
|
+
- [Terraform Module Development](https://developer.hashicorp.com/terraform/language/modules/develop)
|
|
532
|
+
- [Module Best Practices](https://developer.hashicorp.com/terraform/cloud-docs/registry/design)
|
|
533
|
+
|
|
534
|
+
## Revision History
|
|
535
|
+
|
|
536
|
+
| Version | Date | Changes |
|
|
537
|
+
|---------|------|---------|
|
|
538
|
+
| 1.0.0 | 2025-11-07 | Initial skill definition |
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: social-media-marketing
|
|
3
|
+
description: Use when running marketing, social media, content performance, audience signal, campaign reporting, or daily media analysis tasks through OpenGeni social account connectors and MCP tools.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Social Media Marketing
|
|
7
|
+
|
|
8
|
+
Use this skill for scheduled or ad hoc marketing analysis over connected social media accounts.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Call `opengeni__social_daily_analysis_context` first with the selected `connectionIds`, `documentBaseIds`, and a 24 hour window unless the user requested another window.
|
|
13
|
+
2. If you need narrower post data, call `opengeni__social_posts_recent` with explicit connection IDs and date bounds.
|
|
14
|
+
3. If document base IDs are available, use the docs MCP search tools for brand voice, campaign calendars, audience research, messaging rules, and reporting definitions.
|
|
15
|
+
4. Produce a report with:
|
|
16
|
+
- Executive summary
|
|
17
|
+
- Notable account changes
|
|
18
|
+
- Winning posts
|
|
19
|
+
- Underperforming posts
|
|
20
|
+
- Audience and content signals
|
|
21
|
+
- Recommended actions for the next 24 hours
|
|
22
|
+
- Data gaps and caveats
|
|
23
|
+
|
|
24
|
+
## Analysis Rules
|
|
25
|
+
|
|
26
|
+
- Use only metrics, posts, account data, and document snippets returned by tools.
|
|
27
|
+
- Do not invent impressions, engagement, conversions, sentiment, follower counts, or platform capabilities.
|
|
28
|
+
- Treat missing metrics as missing data and say what integration or provider sync would be needed.
|
|
29
|
+
- Compare posts with like-for-like metrics from the same platform when possible.
|
|
30
|
+
- Keep recommendations concrete: target account, content theme, suggested action, expected signal to monitor.
|
|
31
|
+
- Separate observation from recommendation.
|
|
32
|
+
|
|
33
|
+
## Output Style
|
|
34
|
+
|
|
35
|
+
Prefer a concise structured report. Include exact post URLs or external IDs when available. If there are no posts in the window, provide account-level gaps and next data collection steps instead of filler analysis.
|