@punks/cli 2.5.2 → 2.5.3
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/BASELINE_CHANGELOG.md +24 -0
- package/dist/CHANGELOG.md +31 -0
- package/dist/index.js +95 -6
- package/dist/skills/agnostic/backend/backend-domain-structure/SKILL.md +18 -6
- package/dist/skills/agnostic/backend/backend-domain-structure/references/layout.md +61 -3
- package/dist/skills/frameworks/pulumi/package-usage/SKILL.md +49 -0
- package/dist/skills/frameworks/pulumi/package-usage/agents/openai.yaml +4 -0
- package/dist/skills/frameworks/pulumi/package-usage/use_cases.yaml +15 -0
- package/dist/skills/frameworks/pulumi/provider-upgrade/SKILL.md +332 -0
- package/dist/skills/frameworks/pulumi/provider-upgrade/agents/openai.yaml +4 -0
- package/dist/skills/frameworks/pulumi/provider-upgrade/references/diagnostic-toolbox.md +131 -0
- package/dist/skills/frameworks/pulumi/provider-upgrade/use_cases.yaml +28 -0
- package/dist/skills/frameworks/pulumi/pulumi-automation-api/SKILL.md +320 -0
- package/dist/skills/frameworks/pulumi/pulumi-automation-api/agents/openai.yaml +4 -0
- package/dist/skills/frameworks/pulumi/pulumi-automation-api/use_cases.yaml +7 -0
- package/dist/skills/frameworks/pulumi/pulumi-best-practices/SKILL.md +501 -0
- package/dist/skills/frameworks/pulumi/pulumi-best-practices/agents/openai.yaml +4 -0
- package/dist/skills/frameworks/pulumi/pulumi-best-practices/use_cases.yaml +7 -0
- package/dist/skills/frameworks/pulumi/pulumi-component/SKILL.md +830 -0
- package/dist/skills/frameworks/pulumi/pulumi-component/agents/openai.yaml +4 -0
- package/dist/skills/frameworks/pulumi/pulumi-component/use_cases.yaml +19 -0
- package/dist/skills/frameworks/pulumi/pulumi-esc/SKILL.md +281 -0
- package/dist/skills/frameworks/pulumi/pulumi-esc/agents/openai.yaml +4 -0
- package/dist/skills/frameworks/pulumi/pulumi-esc/use_cases.yaml +30 -0
- package/dist/skills/frameworks/pulumi/pulumi-overview/SKILL.md +289 -0
- package/dist/skills/frameworks/pulumi/pulumi-overview/use_cases.yaml +50 -0
- package/dist/skills/phases/goalify/SKILL.md +18 -54
- package/package.json +1 -1
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pulumi-automation-api
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
description: Load this skill when a user asks how to run Pulumi programmatically, embed Pulumi in an application, orchestrate multiple stacks in code, build a self-service infrastructure portal, replace pulumi CLI shell scripts with code, or use the Pulumi Automation API (LocalWorkspace, createOrSelectStack, inline programs). Also load for questions about multi-stack sequencing, parallel deployments, or passing outputs between stacks via code.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pulumi Automation API
|
|
8
|
+
|
|
9
|
+
## When to Use This Skill
|
|
10
|
+
|
|
11
|
+
Invoke this skill when:
|
|
12
|
+
|
|
13
|
+
- Orchestrating deployments across multiple Pulumi stacks
|
|
14
|
+
- Embedding Pulumi operations in custom applications
|
|
15
|
+
- Building self-service infrastructure platforms
|
|
16
|
+
- Replacing fragile Bash/Makefile orchestration scripts
|
|
17
|
+
- Creating custom CLIs for infrastructure management
|
|
18
|
+
- Building web applications that provision infrastructure
|
|
19
|
+
|
|
20
|
+
## What is Automation API
|
|
21
|
+
|
|
22
|
+
Automation API provides programmatic access to Pulumi operations. Instead of running `pulumi up` from the CLI, you call functions in your code that perform the same operations.
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import * as automation from "@pulumi/pulumi/automation";
|
|
26
|
+
|
|
27
|
+
// Create or select a stack
|
|
28
|
+
const stack = await automation.LocalWorkspace.createOrSelectStack({
|
|
29
|
+
stackName: "dev",
|
|
30
|
+
projectName: "my-project",
|
|
31
|
+
program: async () => {
|
|
32
|
+
// Your Pulumi program here
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Run pulumi up programmatically
|
|
37
|
+
const upResult = await stack.up({ onOutput: console.log });
|
|
38
|
+
console.log(`Update summary: ${JSON.stringify(upResult.summary)}`);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## When to Use Automation API
|
|
42
|
+
|
|
43
|
+
### Good Use Cases
|
|
44
|
+
|
|
45
|
+
**Multi-stack orchestration:**
|
|
46
|
+
|
|
47
|
+
When you split infrastructure into multiple focused projects, Automation API helps offset the added complexity by orchestrating operations across stacks:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
infrastructure → platform → application
|
|
51
|
+
↓ ↓ ↓
|
|
52
|
+
(VPC) (Kubernetes) (Services)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Automation API ensures correct sequencing without manual intervention.
|
|
56
|
+
|
|
57
|
+
**Self-service platforms:**
|
|
58
|
+
|
|
59
|
+
Build internal tools where developers request infrastructure without learning Pulumi:
|
|
60
|
+
|
|
61
|
+
- Web portals for environment provisioning
|
|
62
|
+
- Slack bots that create/destroy resources
|
|
63
|
+
- Custom CLIs tailored to your organization
|
|
64
|
+
|
|
65
|
+
**Embedded infrastructure:**
|
|
66
|
+
|
|
67
|
+
Applications that provision their own infrastructure:
|
|
68
|
+
|
|
69
|
+
- SaaS platforms creating per-tenant resources
|
|
70
|
+
- Testing frameworks spinning up test environments
|
|
71
|
+
- CI/CD systems with dynamic infrastructure needs
|
|
72
|
+
|
|
73
|
+
**Replacing fragile scripts:**
|
|
74
|
+
|
|
75
|
+
If you have Bash scripts or Makefiles stitching together multiple `pulumi` commands, Automation API provides:
|
|
76
|
+
|
|
77
|
+
- Proper error handling
|
|
78
|
+
- Type safety
|
|
79
|
+
- Programmatic access to outputs
|
|
80
|
+
|
|
81
|
+
### When NOT to Use
|
|
82
|
+
|
|
83
|
+
- Single project with standard deployment needs
|
|
84
|
+
- When you don't need programmatic control over operations
|
|
85
|
+
|
|
86
|
+
## Architecture Choices
|
|
87
|
+
|
|
88
|
+
### Local Source vs Inline Source
|
|
89
|
+
|
|
90
|
+
**Local Source** - Pulumi program in separate files:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
const stack = await automation.LocalWorkspace.createOrSelectStack({
|
|
94
|
+
stackName: "dev",
|
|
95
|
+
workDir: "./infrastructure", // Points to existing Pulumi project
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**When to use:**
|
|
100
|
+
|
|
101
|
+
- Different teams maintain orchestrator vs Pulumi programs
|
|
102
|
+
- Pulumi programs already exist
|
|
103
|
+
- Want independent version control and release cycles
|
|
104
|
+
- Platform team orchestrating application team's infrastructure
|
|
105
|
+
|
|
106
|
+
**Inline Source** - Pulumi program embedded in orchestrator:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import * as aws from "@pulumi/aws";
|
|
110
|
+
|
|
111
|
+
const stack = await automation.LocalWorkspace.createOrSelectStack({
|
|
112
|
+
stackName: "dev",
|
|
113
|
+
projectName: "my-project",
|
|
114
|
+
program: async () => {
|
|
115
|
+
const bucket = new aws.s3.Bucket("my-bucket");
|
|
116
|
+
return { bucketName: bucket.id };
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**When to use:**
|
|
122
|
+
|
|
123
|
+
- Single team owns everything
|
|
124
|
+
- Tight coupling between orchestration and infrastructure is desired
|
|
125
|
+
- Distributing as compiled binary (no source files needed)
|
|
126
|
+
- Simpler deployment artifact
|
|
127
|
+
|
|
128
|
+
### Language Independence
|
|
129
|
+
|
|
130
|
+
The Automation API program can use a different language than the Pulumi programs it orchestrates:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
Orchestrator (Go) → manages → Pulumi Program (TypeScript)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
This enables platform teams to use their preferred language while application teams use theirs.
|
|
137
|
+
|
|
138
|
+
## Common Patterns
|
|
139
|
+
|
|
140
|
+
### Multi-Stack Orchestration
|
|
141
|
+
|
|
142
|
+
Deploy multiple stacks in dependency order:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import * as automation from "@pulumi/pulumi/automation";
|
|
146
|
+
|
|
147
|
+
async function deploy() {
|
|
148
|
+
const stacks = [
|
|
149
|
+
{ name: "infrastructure", dir: "./infra" },
|
|
150
|
+
{ name: "platform", dir: "./platform" },
|
|
151
|
+
{ name: "application", dir: "./app" },
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
for (const stackInfo of stacks) {
|
|
155
|
+
console.log(`Deploying ${stackInfo.name}...`);
|
|
156
|
+
|
|
157
|
+
const stack = await automation.LocalWorkspace.createOrSelectStack({
|
|
158
|
+
stackName: "prod",
|
|
159
|
+
workDir: stackInfo.dir,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
await stack.up({ onOutput: console.log });
|
|
163
|
+
console.log(`${stackInfo.name} deployed successfully`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function destroy() {
|
|
168
|
+
// Destroy in reverse order
|
|
169
|
+
const stacks = [
|
|
170
|
+
{ name: "application", dir: "./app" },
|
|
171
|
+
{ name: "platform", dir: "./platform" },
|
|
172
|
+
{ name: "infrastructure", dir: "./infra" },
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
for (const stackInfo of stacks) {
|
|
176
|
+
console.log(`Destroying ${stackInfo.name}...`);
|
|
177
|
+
|
|
178
|
+
const stack = await automation.LocalWorkspace.selectStack({
|
|
179
|
+
stackName: "prod",
|
|
180
|
+
workDir: stackInfo.dir,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
await stack.destroy({ onOutput: console.log });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Passing Configuration
|
|
189
|
+
|
|
190
|
+
Set stack configuration programmatically:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
const stack = await automation.LocalWorkspace.createOrSelectStack({
|
|
194
|
+
stackName: "dev",
|
|
195
|
+
workDir: "./infrastructure",
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Set configuration values
|
|
199
|
+
await stack.setConfig("aws:region", { value: "us-west-2" });
|
|
200
|
+
await stack.setConfig("dbPassword", { value: "secret", secret: true });
|
|
201
|
+
|
|
202
|
+
// Then deploy
|
|
203
|
+
await stack.up();
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Reading Outputs
|
|
207
|
+
|
|
208
|
+
Access stack outputs after deployment:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
const upResult = await stack.up();
|
|
212
|
+
|
|
213
|
+
// Get all outputs
|
|
214
|
+
const outputs = await stack.outputs();
|
|
215
|
+
console.log(`VPC ID: ${outputs["vpcId"].value}`);
|
|
216
|
+
|
|
217
|
+
// Or from the up result
|
|
218
|
+
console.log(`Outputs: ${JSON.stringify(upResult.outputs)}`);
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Error Handling
|
|
222
|
+
|
|
223
|
+
Handle deployment failures gracefully:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
try {
|
|
227
|
+
const result = await stack.up({ onOutput: console.log });
|
|
228
|
+
|
|
229
|
+
if (result.summary.result === "failed") {
|
|
230
|
+
console.error("Deployment failed");
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
} catch (error) {
|
|
234
|
+
console.error(`Deployment error: ${error}`);
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Parallel Stack Operations
|
|
240
|
+
|
|
241
|
+
When stacks are independent, deploy in parallel:
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
const independentStacks = [
|
|
245
|
+
{ name: "service-a", dir: "./service-a" },
|
|
246
|
+
{ name: "service-b", dir: "./service-b" },
|
|
247
|
+
{ name: "service-c", dir: "./service-c" },
|
|
248
|
+
];
|
|
249
|
+
|
|
250
|
+
await Promise.all(independentStacks.map(async (stackInfo) => {
|
|
251
|
+
const stack = await automation.LocalWorkspace.createOrSelectStack({
|
|
252
|
+
stackName: "prod",
|
|
253
|
+
workDir: stackInfo.dir,
|
|
254
|
+
});
|
|
255
|
+
return stack.up({ onOutput: (msg) => console.log(`[${stackInfo.name}] ${msg}`) });
|
|
256
|
+
}));
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Best Practices
|
|
260
|
+
|
|
261
|
+
### Separate Configuration from Code
|
|
262
|
+
|
|
263
|
+
Externalize configuration into files or environment variables:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
import * as fs from "fs";
|
|
267
|
+
|
|
268
|
+
interface DeployConfig {
|
|
269
|
+
stacks: Array<{ name: string; dir: string; }>;
|
|
270
|
+
environment: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const config: DeployConfig = JSON.parse(
|
|
274
|
+
fs.readFileSync("./deploy-config.json", "utf-8")
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
for (const stackInfo of config.stacks) {
|
|
278
|
+
const stack = await automation.LocalWorkspace.createOrSelectStack({
|
|
279
|
+
stackName: config.environment,
|
|
280
|
+
workDir: stackInfo.dir,
|
|
281
|
+
});
|
|
282
|
+
await stack.up();
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
This enables distributing compiled binaries without exposing source code.
|
|
287
|
+
|
|
288
|
+
### Stream Output for Long Operations
|
|
289
|
+
|
|
290
|
+
Use `onOutput` callback for real-time feedback:
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
await stack.up({
|
|
294
|
+
onOutput: (message) => {
|
|
295
|
+
process.stdout.write(message);
|
|
296
|
+
// Or send to logging system, websocket, etc.
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Quick Reference
|
|
302
|
+
|
|
303
|
+
| Scenario | Approach |
|
|
304
|
+
| --- | --- |
|
|
305
|
+
| Existing Pulumi projects | Local source with workDir |
|
|
306
|
+
| New embedded infrastructure | Inline source with program function |
|
|
307
|
+
| Different teams | Local source for independence |
|
|
308
|
+
| Compiled binary distribution | Inline source or bundled local |
|
|
309
|
+
| Multi-stack dependencies | Sequential deployment in order |
|
|
310
|
+
| Independent stacks | Parallel deployment with Promise.all |
|
|
311
|
+
|
|
312
|
+
## Related Skills
|
|
313
|
+
|
|
314
|
+
- **pulumi-best-practices**: Code-level patterns for Pulumi programs
|
|
315
|
+
|
|
316
|
+
## References
|
|
317
|
+
|
|
318
|
+
- https://www.pulumi.com/docs/using-pulumi/automation-api/
|
|
319
|
+
- https://www.pulumi.com/docs/using-pulumi/automation-api/concepts-terminology/
|
|
320
|
+
- https://www.pulumi.com/blog/iac-recommended-practices-using-automation-api/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Queries that should activate the pulumi-automation-api skill
|
|
2
|
+
queries:
|
|
3
|
+
- "Help me use the Pulumi Automation API to deploy stacks from my Go program"
|
|
4
|
+
- "Write a Python script that uses Pulumi Automation API to manage stacks"
|
|
5
|
+
- "How do I embed Pulumi into my CI/CD platform using the Automation API?"
|
|
6
|
+
- "Create a LocalWorkspace with the Pulumi Automation API in TypeScript"
|
|
7
|
+
- "I want to run pulumi up programmatically from my application code"
|