@punks/cli 2.5.1 → 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/AGENTS.md +2 -2
- package/README.md +5 -5
- package/dist/BASELINE_CHANGELOG.md +39 -0
- package/dist/CHANGELOG.md +63 -0
- package/dist/data/hooks/format-edited-file.mjs +20 -0
- package/dist/index.js +255 -37
- 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/agnostic/cli/{dp-cli → hi-cli}/SKILL.md +3 -3
- package/dist/skills/agnostic/cli/{dp-cli → hi-cli}/references/commands.md +1 -1
- package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +2 -2
- 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/misc/timesheet/SKILL.md +87 -0
- package/dist/skills/misc/timesheet/scripts/git-timesheet-evidence.mjs +214 -0
- package/dist/skills/phases/goalify/SKILL.md +18 -54
- package/package.json +1 -1
- /package/dist/skills/agnostic/cli/{dp-cli → hi-cli}/references/post-command-flow.md +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Diagnostic Toolbox
|
|
2
|
+
|
|
3
|
+
Use these tools to investigate diffs - especially Category B diffs (resources you didn't
|
|
4
|
+
change code for). Reach for whichever tool fits the situation.
|
|
5
|
+
|
|
6
|
+
For major version upgrades, check the upgrade guide early - even alongside the first
|
|
7
|
+
preview. Upgrade guides contain sequencing requirements and edge cases that no other
|
|
8
|
+
tool can surface.
|
|
9
|
+
|
|
10
|
+
## Upgrade Guide (Pulumi or Terraform)
|
|
11
|
+
|
|
12
|
+
The most valuable resource for major version bumps. Contains migration patterns,
|
|
13
|
+
sequencing requirements, and documents which diffs are known preview artifacts.
|
|
14
|
+
|
|
15
|
+
The upgrade guide is the ONLY authoritative source for classifying a diff as a "known
|
|
16
|
+
no-op" - a diff that shows in preview but resolves on `pulumi up` without affecting
|
|
17
|
+
real infrastructure.
|
|
18
|
+
|
|
19
|
+
**Pulumi upgrade guide:**
|
|
20
|
+
Search for `site:pulumi.com {provider} migration guide v{major}`.
|
|
21
|
+
|
|
22
|
+
**Terraform upgrade guide** (for Terraform-based providers):
|
|
23
|
+
Check `https://registry.terraform.io/providers/{org}/{tf-provider}/latest/docs/guides/version-{major}-upgrade`
|
|
24
|
+
or search for `site:registry.terraform.io {tf-provider} version {major} upgrade`.
|
|
25
|
+
|
|
26
|
+
**When to use:** For any major version upgrade. Check it early.
|
|
27
|
+
|
|
28
|
+
## schema-tools - structured diff between versions
|
|
29
|
+
|
|
30
|
+
A structured diff of every schema change between provider versions. For large providers,
|
|
31
|
+
the diff can contain thousands of changes - always cross-reference with the resource
|
|
32
|
+
types actually present in the stack.
|
|
33
|
+
|
|
34
|
+
**Install** (if not available):
|
|
35
|
+
|
|
36
|
+
This example is intentionally lightweight and may drift over time. If the pinned version
|
|
37
|
+
below is stale, use the latest available `schema-tools` release instead of treating the
|
|
38
|
+
example version as authoritative.
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
42
|
+
ARCH=$(uname -m)
|
|
43
|
+
case "$ARCH" in x86_64) ARCH="amd64" ;; aarch64|arm64) ARCH="arm64" ;; esac
|
|
44
|
+
VERSION="v0.7.0"
|
|
45
|
+
curl -fsSL "https://github.com/pulumi/schema-tools/releases/download/${VERSION}/schema-tools-${VERSION}-${OS}-${ARCH}.tar.gz" \
|
|
46
|
+
-o /tmp/schema-tools.tar.gz
|
|
47
|
+
tar -xzf /tmp/schema-tools.tar.gz -C /tmp/
|
|
48
|
+
chmod +x /tmp/schema-tools
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Run and save to a file:**
|
|
52
|
+
|
|
53
|
+
```shell
|
|
54
|
+
/tmp/schema-tools compare -p {provider} -o v{current_version} -n v{target_version} --json > /tmp/{provider}-schema-diff.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The `-o` and `-n` flags must be full version tags (e.g., `v6.0.0`, `v7.0.0`), not just
|
|
58
|
+
major numbers. Use the exact versions from the lockfile.
|
|
59
|
+
|
|
60
|
+
**Useful queries:**
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
# Summary of all breaking change categories
|
|
64
|
+
jq '.summary' /tmp/{provider}-schema-diff.json
|
|
65
|
+
|
|
66
|
+
# Changes for a specific resource
|
|
67
|
+
jq '.grouped.resources["aws:s3/bucket:Bucket"]' /tmp/{provider}-schema-diff.json
|
|
68
|
+
|
|
69
|
+
# All changes of a specific type
|
|
70
|
+
jq '[.changes[] | select(.kind == "missing-input")]' /tmp/{provider}-schema-diff.json
|
|
71
|
+
|
|
72
|
+
# All breaking changes matching a pattern
|
|
73
|
+
jq '[.changes[] | select(.token | test("apigateway"))]' /tmp/{provider}-schema-diff.json
|
|
74
|
+
|
|
75
|
+
# List all affected resource tokens
|
|
76
|
+
jq '[.changes[] | .token] | unique' /tmp/{provider}-schema-diff.json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Each change entry has `kind`, `token`, `severity`, and `message` fields. The change
|
|
80
|
+
kinds you'll encounter most often during upgrades:
|
|
81
|
+
|
|
82
|
+
- **missing-input** - a property was removed from inputs. Usually renamed or replaced by
|
|
83
|
+
a different property with a different shape. The schema diff says it's gone but doesn't
|
|
84
|
+
say what replaced it - check the upgrade guide or new schema for the replacement.
|
|
85
|
+
- **type-changed** - a property's type changed. The most common pattern is a MaxItemsOne
|
|
86
|
+
flip: a property is renamed AND changes between single object and array (or vice versa).
|
|
87
|
+
Example: `certificateAuthorities` (array) -> `certificateAuthority` (single object).
|
|
88
|
+
- **token-remapped** - a resource or function was renamed. If "deprecated," the old name
|
|
89
|
+
still works (don't chase it). If "remapped," the old name is gone - rename in code and
|
|
90
|
+
add an alias to preserve state: `aliases: [{ type: "old:token:Name" }]`.
|
|
91
|
+
|
|
92
|
+
**When to use:** When preview errors mention unknown properties, missing fields, type
|
|
93
|
+
mismatches, or unrecognized resource types. The schema diff tells you exactly what was
|
|
94
|
+
renamed, removed, or reshaped.
|
|
95
|
+
|
|
96
|
+
## Stack state inspection - scope changes to this stack
|
|
97
|
+
|
|
98
|
+
Inspect the stack's deployed resource types. Essential for large providers - filter the
|
|
99
|
+
schema diff to only resources that matter. Use whatever state inspection tooling is
|
|
100
|
+
available in the environment, such as `pulumi stack --show-urns`, `pulumi stack export`,
|
|
101
|
+
state files, or backend resource inventory APIs.
|
|
102
|
+
|
|
103
|
+
```shell
|
|
104
|
+
# Example: list resource types from a stack export
|
|
105
|
+
pulumi stack export > /tmp/stack.json
|
|
106
|
+
jq -r '.deployment.resources[].type' /tmp/stack.json | sort -u
|
|
107
|
+
|
|
108
|
+
# Then filter schema diff to only resource types in the stack
|
|
109
|
+
jq '[.changes[] | select(.token | test("ZoneSettingsOverride|PageRule|Record|Zone"))]' \
|
|
110
|
+
/tmp/{provider}-schema-diff.json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**When to use:** Always use alongside schema-tools.
|
|
114
|
+
|
|
115
|
+
## SDK type definitions - inspect the new API shape
|
|
116
|
+
|
|
117
|
+
For TypeScript and Python projects, the installed package's type definitions show the
|
|
118
|
+
exact new API - property names, types, required vs. optional.
|
|
119
|
+
|
|
120
|
+
**TypeScript:** read `node_modules/@pulumi/{provider}/*.d.ts` for the resource type
|
|
121
|
+
**Python:** read the installed package source
|
|
122
|
+
|
|
123
|
+
Faster than schema-tools for answering "what does this resource look like now?"
|
|
124
|
+
|
|
125
|
+
## GitHub issues
|
|
126
|
+
|
|
127
|
+
Search `pulumi/pulumi-{provider}` and `hashicorp/terraform-provider-{tf-name}` for
|
|
128
|
+
specific error messages or resource names.
|
|
129
|
+
|
|
130
|
+
**When to use:** When upgrade guides don't cover an edge case, or when you're seeing
|
|
131
|
+
unexpected behavior that might be a known bug.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Queries that should activate the provider-upgrade skill
|
|
2
|
+
queries:
|
|
3
|
+
# Explicit upgrade requests
|
|
4
|
+
- "Upgrade the pulumi-aws provider in my project to the latest version"
|
|
5
|
+
- "How do I upgrade from pulumi-aws v5 to v6?"
|
|
6
|
+
- "Bump the pulumi-azure-native provider to v3 in my TypeScript project"
|
|
7
|
+
- "Upgrade pulumi-kubernetes from v3 to v4 across my stacks"
|
|
8
|
+
- "Update my GCP provider to the latest version"
|
|
9
|
+
- "Upgrade the Pulumi Cloudflare provider in this repo"
|
|
10
|
+
- "Help me bump the Datadog provider without changing real infrastructure"
|
|
11
|
+
|
|
12
|
+
# Breaking changes / migration
|
|
13
|
+
- "What are the breaking changes when upgrading pulumi-aws from v5 to v6?"
|
|
14
|
+
- "Is there a migration guide for pulumi-azure-native v2 to v3?"
|
|
15
|
+
- "The aws provider upgrade broke my S3 bucket resource, how do I fix it?"
|
|
16
|
+
- "After upgrading pulumi-aws, my preview shows resource replacements I didn't expect"
|
|
17
|
+
- "How do I add an alias for a renamed resource after a provider major version bump?"
|
|
18
|
+
- "My provider upgrade preview shows a create for infrastructure that already exists"
|
|
19
|
+
- "How do I handle deletes after a Pulumi provider major version upgrade?"
|
|
20
|
+
|
|
21
|
+
# Dependency management
|
|
22
|
+
- "How do I update @pulumi/aws to a newer version in my npm project?"
|
|
23
|
+
- "Update the pulumi_aws dependency in my Python requirements.txt"
|
|
24
|
+
- "Run go get to upgrade the Pulumi AWS provider SDK to the latest major version"
|
|
25
|
+
|
|
26
|
+
# Workflow / process questions
|
|
27
|
+
- "Walk me through upgrading the kubernetes provider without breaking my production stack"
|
|
28
|
+
- "What's the safe process for upgrading a Pulumi provider in a team environment?"
|
|
@@ -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"
|