@punks/cli 2.5.2 → 2.5.4

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.
Files changed (43) hide show
  1. package/dist/BASELINE_CHANGELOG.md +48 -0
  2. package/dist/CHANGELOG.md +60 -0
  3. package/dist/index.js +100 -7
  4. package/dist/skills/agnostic/backend/backend-domain-structure/SKILL.md +18 -6
  5. package/dist/skills/agnostic/backend/backend-domain-structure/references/layout.md +61 -3
  6. package/dist/skills/frameworks/pulumi/package-usage/SKILL.md +49 -0
  7. package/dist/skills/frameworks/pulumi/package-usage/agents/openai.yaml +4 -0
  8. package/dist/skills/frameworks/pulumi/package-usage/use_cases.yaml +15 -0
  9. package/dist/skills/frameworks/pulumi/provider-upgrade/SKILL.md +332 -0
  10. package/dist/skills/frameworks/pulumi/provider-upgrade/agents/openai.yaml +4 -0
  11. package/dist/skills/frameworks/pulumi/provider-upgrade/references/diagnostic-toolbox.md +131 -0
  12. package/dist/skills/frameworks/pulumi/provider-upgrade/use_cases.yaml +28 -0
  13. package/dist/skills/frameworks/pulumi/pulumi-automation-api/SKILL.md +320 -0
  14. package/dist/skills/frameworks/pulumi/pulumi-automation-api/agents/openai.yaml +4 -0
  15. package/dist/skills/frameworks/pulumi/pulumi-automation-api/use_cases.yaml +7 -0
  16. package/dist/skills/frameworks/pulumi/pulumi-best-practices/SKILL.md +501 -0
  17. package/dist/skills/frameworks/pulumi/pulumi-best-practices/agents/openai.yaml +4 -0
  18. package/dist/skills/frameworks/pulumi/pulumi-best-practices/use_cases.yaml +7 -0
  19. package/dist/skills/frameworks/pulumi/pulumi-component/SKILL.md +830 -0
  20. package/dist/skills/frameworks/pulumi/pulumi-component/agents/openai.yaml +4 -0
  21. package/dist/skills/frameworks/pulumi/pulumi-component/use_cases.yaml +19 -0
  22. package/dist/skills/frameworks/pulumi/pulumi-esc/SKILL.md +281 -0
  23. package/dist/skills/frameworks/pulumi/pulumi-esc/agents/openai.yaml +4 -0
  24. package/dist/skills/frameworks/pulumi/pulumi-esc/use_cases.yaml +30 -0
  25. package/dist/skills/frameworks/pulumi/pulumi-overview/SKILL.md +289 -0
  26. package/dist/skills/frameworks/pulumi/pulumi-overview/use_cases.yaml +50 -0
  27. package/dist/skills/phases/bug-discovery-phase/SKILL.md +1 -0
  28. package/dist/skills/phases/bug-discovery-phase/agents/openai.yaml +2 -0
  29. package/dist/skills/phases/bug-resolution-phase/SKILL.md +1 -0
  30. package/dist/skills/phases/bug-resolution-phase/agents/openai.yaml +2 -0
  31. package/dist/skills/phases/delivery-phase/SKILL.md +1 -0
  32. package/dist/skills/phases/delivery-phase/agents/openai.yaml +2 -0
  33. package/dist/skills/phases/design-phase/SKILL.md +3 -2
  34. package/dist/skills/phases/design-phase/agents/openai.yaml +2 -0
  35. package/dist/skills/phases/design-phase/phases/delivery-handoff.md +5 -5
  36. package/dist/skills/phases/finder-phase/SKILL.md +1 -0
  37. package/dist/skills/phases/finder-phase/agents/openai.yaml +2 -0
  38. package/dist/skills/phases/goalify/SKILL.md +18 -54
  39. package/dist/skills/phases/requirements-phase/SKILL.md +1 -0
  40. package/dist/skills/phases/requirements-phase/agents/openai.yaml +2 -0
  41. package/dist/skills/phases/resolve-debt-phase/SKILL.md +7 -5
  42. package/dist/skills/phases/resolve-debt-phase/agents/openai.yaml +2 -0
  43. package/package.json +1 -1
@@ -0,0 +1,830 @@
1
+ ---
2
+ name: pulumi-component
3
+ version: 1.0.0
4
+ description: Guide for authoring Pulumi ComponentResource classes. Use when creating reusable infrastructure components, designing component interfaces, setting up multi-language support, or distributing component packages.
5
+ ---
6
+
7
+ # Authoring Pulumi Components
8
+
9
+ A ComponentResource groups related infrastructure resources into a reusable, logical unit. Components make infrastructure easier to understand, reuse, and maintain. Components appear as a single node with children nested underneath in `pulumi preview`/`pulumi up` output and in the Pulumi Cloud console.
10
+
11
+ This skill covers the full component authoring lifecycle. For general Pulumi coding patterns (Output handling, secrets, aliases, preview workflows), use the `pulumi-best-practices` skill instead.
12
+
13
+ ## When to Use This Skill
14
+
15
+ Invoke this skill when:
16
+
17
+ - Creating a new ComponentResource class
18
+ - Designing the args interface for a component
19
+ - Making a component consumable from multiple Pulumi languages
20
+ - Publishing or distributing a component package
21
+ - Refactoring inline resources into a reusable component
22
+ - Debugging component behavior (missing outputs, stuck creating, children at wrong level)
23
+
24
+ ## Component Anatomy
25
+
26
+ Every component has four required elements:
27
+
28
+ 1. **Extend ComponentResource** and call `super()` with a type URN
29
+ 2. **Accept standard parameters**: name, args, and `ComponentResourceOptions`
30
+ 3. **Set `parent: this`** on all child resources
31
+ 4. **Call `registerOutputs()`** at the end of the constructor
32
+
33
+ ### TypeScript
34
+
35
+ ```typescript
36
+ import * as pulumi from "@pulumi/pulumi";
37
+ import * as aws from "@pulumi/aws";
38
+
39
+ interface StaticSiteArgs {
40
+ indexDocument?: pulumi.Input<string>;
41
+ errorDocument?: pulumi.Input<string>;
42
+ }
43
+
44
+ class StaticSite extends pulumi.ComponentResource {
45
+ public readonly bucketName: pulumi.Output<string>;
46
+ public readonly websiteUrl: pulumi.Output<string>;
47
+
48
+ constructor(name: string, args: StaticSiteArgs, opts?: pulumi.ComponentResourceOptions) {
49
+ // 1. Call super with type URN: <package>:<module>:<type>
50
+ super("myorg:index:StaticSite", name, {}, opts);
51
+
52
+ // 2. Create child resources with parent: this
53
+ const bucket = new aws.s3.Bucket(`${name}-bucket`, {}, { parent: this });
54
+
55
+ const website = new aws.s3.BucketWebsiteConfigurationV2(`${name}-website`, {
56
+ bucket: bucket.id,
57
+ indexDocument: { suffix: args.indexDocument ?? "index.html" },
58
+ errorDocument: { key: args.errorDocument ?? "error.html" },
59
+ }, { parent: this });
60
+
61
+ // 3. Expose outputs as class properties
62
+ this.bucketName = bucket.id;
63
+ this.websiteUrl = website.websiteEndpoint;
64
+
65
+ // 4. Register outputs -- always the last line
66
+ this.registerOutputs({
67
+ bucketName: this.bucketName,
68
+ websiteUrl: this.websiteUrl,
69
+ });
70
+ }
71
+ }
72
+
73
+ // Usage
74
+ const site = new StaticSite("marketing", {
75
+ indexDocument: "index.html",
76
+ });
77
+ export const url = site.websiteUrl;
78
+ ```
79
+
80
+ ### Python
81
+
82
+ ```python
83
+ import pulumi
84
+ import pulumi_aws as aws
85
+
86
+ class StaticSiteArgs:
87
+ def __init__(self,
88
+ index_document: pulumi.Input[str] = "index.html",
89
+ error_document: pulumi.Input[str] = "error.html"):
90
+ self.index_document = index_document
91
+ self.error_document = error_document
92
+
93
+ class StaticSite(pulumi.ComponentResource):
94
+ bucket_name: pulumi.Output[str]
95
+ website_url: pulumi.Output[str]
96
+
97
+ def __init__(self, name: str, args: StaticSiteArgs,
98
+ opts: pulumi.ResourceOptions = None):
99
+ super().__init__("myorg:index:StaticSite", name, None, opts)
100
+
101
+ bucket = aws.s3.Bucket(f"{name}-bucket",
102
+ opts=pulumi.ResourceOptions(parent=self))
103
+
104
+ website = aws.s3.BucketWebsiteConfigurationV2(f"{name}-website",
105
+ bucket=bucket.id,
106
+ index_document=aws.s3.BucketWebsiteConfigurationV2IndexDocumentArgs(
107
+ suffix=args.index_document,
108
+ ),
109
+ error_document=aws.s3.BucketWebsiteConfigurationV2ErrorDocumentArgs(
110
+ key=args.error_document,
111
+ ),
112
+ opts=pulumi.ResourceOptions(parent=self))
113
+
114
+ self.bucket_name = bucket.id
115
+ self.website_url = website.website_endpoint
116
+
117
+ self.register_outputs({
118
+ "bucket_name": self.bucket_name,
119
+ "website_url": self.website_url,
120
+ })
121
+
122
+ site = StaticSite("marketing", StaticSiteArgs())
123
+ pulumi.export("url", site.website_url)
124
+ ```
125
+
126
+ ### Type URN Format
127
+
128
+ The first argument to `super()` is the type URN: `<package>:<module>:<type>`.
129
+
130
+ | Segment | Convention | Example |
131
+ |---------|-----------|---------|
132
+ | package | Organization or package name | `myorg`, `acme`, `pkg` |
133
+ | module | Usually `index` | `index` |
134
+ | type | PascalCase class name | `StaticSite`, `VpcNetwork` |
135
+
136
+ Full examples: `myorg:index:StaticSite`, `acme:index:KubernetesCluster`
137
+
138
+ ### registerOutputs Is Required
139
+
140
+ **Why**: Without `registerOutputs()`, the component appears stuck in a "creating" state in the Pulumi console and outputs are not persisted to state.
141
+
142
+ **Wrong**:
143
+
144
+ ```typescript
145
+ class MyComponent extends pulumi.ComponentResource {
146
+ public readonly url: pulumi.Output<string>;
147
+
148
+ constructor(name: string, args: MyArgs, opts?: pulumi.ComponentResourceOptions) {
149
+ super("myorg:index:MyComponent", name, {}, opts);
150
+ const bucket = new aws.s3.Bucket(`${name}-bucket`, {}, { parent: this });
151
+ this.url = bucket.bucketRegionalDomainName;
152
+ // Missing registerOutputs -- component stuck "creating"
153
+ }
154
+ }
155
+ ```
156
+
157
+ **Right**:
158
+
159
+ ```typescript
160
+ class MyComponent extends pulumi.ComponentResource {
161
+ public readonly url: pulumi.Output<string>;
162
+
163
+ constructor(name: string, args: MyArgs, opts?: pulumi.ComponentResourceOptions) {
164
+ super("myorg:index:MyComponent", name, {}, opts);
165
+ const bucket = new aws.s3.Bucket(`${name}-bucket`, {}, { parent: this });
166
+ this.url = bucket.bucketRegionalDomainName;
167
+
168
+ this.registerOutputs({ url: this.url });
169
+ }
170
+ }
171
+ ```
172
+
173
+ ### Derive Child Names from the Component Name
174
+
175
+ **Why**: Hardcoded child names cause collisions when the component is instantiated multiple times.
176
+
177
+ **Wrong**:
178
+
179
+ ```typescript
180
+ // Collides if two instances of this component exist
181
+ const bucket = new aws.s3.Bucket("my-bucket", {}, { parent: this });
182
+ ```
183
+
184
+ **Right**:
185
+
186
+ ```typescript
187
+ // Unique per component instance
188
+ const bucket = new aws.s3.Bucket(`${name}-bucket`, {}, { parent: this });
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Designing the Args Interface
194
+
195
+ The args interface is the most impactful design decision. It defines what consumers can configure and how composable the component is.
196
+
197
+ ### Wrap Properties in Input<T>
198
+
199
+ **Why**: `Input<T>` accepts both plain values and `Output<T>` from other resources. Without it, consumers must unwrap outputs manually with `.apply()`.
200
+
201
+ **Wrong**:
202
+
203
+ ```typescript
204
+ interface WebServiceArgs {
205
+ port: number; // Forces consumers to unwrap Outputs
206
+ vpcId: string; // Cannot accept vpc.id directly
207
+ }
208
+ ```
209
+
210
+ **Right**:
211
+
212
+ ```typescript
213
+ interface WebServiceArgs {
214
+ port: pulumi.Input<number>; // Accepts 8080 or someOutput
215
+ vpcId: pulumi.Input<string>; // Accepts "vpc-123" or vpc.id
216
+ }
217
+ ```
218
+
219
+ ### Keep Structures Flat
220
+
221
+ Avoid deeply nested arg objects. Flat interfaces are easier to use and evolve.
222
+
223
+ ```typescript
224
+ // Prefer flat
225
+ interface DatabaseArgs {
226
+ instanceClass: pulumi.Input<string>;
227
+ storageGb: pulumi.Input<number>;
228
+ enableBackups?: pulumi.Input<boolean>;
229
+ backupRetentionDays?: pulumi.Input<number>;
230
+ }
231
+
232
+ // Avoid deep nesting
233
+ interface DatabaseArgs {
234
+ instance: {
235
+ compute: { class: pulumi.Input<string> };
236
+ storage: { sizeGb: pulumi.Input<number> };
237
+ };
238
+ backup: {
239
+ config: { enabled: pulumi.Input<boolean>; retention: pulumi.Input<number> };
240
+ };
241
+ }
242
+ ```
243
+
244
+ ### No Union Types
245
+
246
+ Union types break multi-language SDK generation. Python, Go, and C# cannot represent `string | number`.
247
+
248
+ **Wrong**:
249
+
250
+ ```typescript
251
+ interface MyArgs {
252
+ port: pulumi.Input<string | number>; // Fails in Python, Go, C#
253
+ }
254
+ ```
255
+
256
+ **Right**:
257
+
258
+ ```typescript
259
+ interface MyArgs {
260
+ port: pulumi.Input<number>; // Single type, works everywhere
261
+ }
262
+ ```
263
+
264
+ If you need to accept multiple forms, use separate optional properties:
265
+
266
+ ```typescript
267
+ interface StorageArgs {
268
+ sizeGb?: pulumi.Input<number>; // Specify size in GB
269
+ sizeMb?: pulumi.Input<number>; // Or specify size in MB
270
+ }
271
+ ```
272
+
273
+ ### No Functions or Callbacks
274
+
275
+ Functions cannot be serialized across language boundaries.
276
+
277
+ **Wrong**:
278
+
279
+ ```typescript
280
+ interface MyArgs {
281
+ nameTransform: (name: string) => string; // Cannot serialize
282
+ }
283
+ ```
284
+
285
+ **Right**:
286
+
287
+ ```typescript
288
+ interface MyArgs {
289
+ namePrefix?: pulumi.Input<string>; // Configuration instead of callback
290
+ nameSuffix?: pulumi.Input<string>;
291
+ }
292
+ ```
293
+
294
+ ### Use Defaults for Optional Properties
295
+
296
+ Set sensible defaults inside the constructor so consumers only configure what they need:
297
+
298
+ ```typescript
299
+ interface SecureBucketArgs {
300
+ enableVersioning?: pulumi.Input<boolean>; // Defaults to true
301
+ enableEncryption?: pulumi.Input<boolean>; // Defaults to true
302
+ blockPublicAccess?: pulumi.Input<boolean>; // Defaults to true
303
+ }
304
+
305
+ class SecureBucket extends pulumi.ComponentResource {
306
+ constructor(name: string, args: SecureBucketArgs, opts?: pulumi.ComponentResourceOptions) {
307
+ super("myorg:index:SecureBucket", name, {}, opts);
308
+
309
+ const enableVersioning = args.enableVersioning ?? true;
310
+ const enableEncryption = args.enableEncryption ?? true;
311
+ const blockPublicAccess = args.blockPublicAccess ?? true;
312
+
313
+ // Apply defaults...
314
+ }
315
+ }
316
+
317
+ // Consumer only overrides what they need
318
+ const bucket = new SecureBucket("data", { enableVersioning: false });
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Exposing Outputs
324
+
325
+ ### Expose Only What Consumers Need
326
+
327
+ Components often create many internal resources. Expose only the values consumers need, not every internal resource.
328
+
329
+ **Wrong**:
330
+
331
+ ```typescript
332
+ class Database extends pulumi.ComponentResource {
333
+ // Exposes everything -- consumers see implementation details
334
+ public readonly cluster: aws.rds.Cluster;
335
+ public readonly primaryInstance: aws.rds.ClusterInstance;
336
+ public readonly replicaInstance: aws.rds.ClusterInstance;
337
+ public readonly subnetGroup: aws.rds.SubnetGroup;
338
+ public readonly securityGroup: aws.ec2.SecurityGroup;
339
+ public readonly parameterGroup: aws.rds.ClusterParameterGroup;
340
+ // ...
341
+ }
342
+ ```
343
+
344
+ **Right**:
345
+
346
+ ```typescript
347
+ class Database extends pulumi.ComponentResource {
348
+ // Exposes only what consumers need
349
+ public readonly endpoint: pulumi.Output<string>;
350
+ public readonly port: pulumi.Output<number>;
351
+ public readonly securityGroupId: pulumi.Output<string>;
352
+
353
+ constructor(name: string, args: DatabaseArgs, opts?: pulumi.ComponentResourceOptions) {
354
+ super("myorg:index:Database", name, {}, opts);
355
+
356
+ const sg = new aws.ec2.SecurityGroup(`${name}-sg`, { /* ... */ }, { parent: this });
357
+ const cluster = new aws.rds.Cluster(`${name}-cluster`, { /* ... */ }, { parent: this });
358
+
359
+ this.endpoint = cluster.endpoint;
360
+ this.port = cluster.port;
361
+ this.securityGroupId = sg.id;
362
+
363
+ this.registerOutputs({
364
+ endpoint: this.endpoint,
365
+ port: this.port,
366
+ securityGroupId: this.securityGroupId,
367
+ });
368
+ }
369
+ }
370
+ ```
371
+
372
+ ### Derive Composite Outputs
373
+
374
+ Use `pulumi.interpolate` or `pulumi.concat` to build derived values:
375
+
376
+ ```typescript
377
+ this.connectionString = pulumi.interpolate`postgresql://${args.username}:${args.password}@${cluster.endpoint}:${cluster.port}/${args.databaseName}`;
378
+
379
+ this.registerOutputs({ connectionString: this.connectionString });
380
+ ```
381
+
382
+ ---
383
+
384
+ ## Component Design Patterns
385
+
386
+ ### Sensible Defaults with Override
387
+
388
+ Encode best practices as defaults. Allow consumers to override when they have specific requirements.
389
+
390
+ ```typescript
391
+ interface SecureBucketArgs {
392
+ enableVersioning?: pulumi.Input<boolean>;
393
+ enableEncryption?: pulumi.Input<boolean>;
394
+ blockPublicAccess?: pulumi.Input<boolean>;
395
+ tags?: pulumi.Input<Record<string, pulumi.Input<string>>>;
396
+ }
397
+
398
+ class SecureBucket extends pulumi.ComponentResource {
399
+ public readonly bucketId: pulumi.Output<string>;
400
+ public readonly arn: pulumi.Output<string>;
401
+
402
+ constructor(name: string, args: SecureBucketArgs = {}, opts?: pulumi.ComponentResourceOptions) {
403
+ super("myorg:index:SecureBucket", name, {}, opts);
404
+
405
+ const bucket = new aws.s3.Bucket(`${name}-bucket`, {
406
+ tags: args.tags,
407
+ }, { parent: this });
408
+
409
+ // Versioning on by default
410
+ if (args.enableVersioning !== false) {
411
+ new aws.s3.BucketVersioningV2(`${name}-versioning`, {
412
+ bucket: bucket.id,
413
+ versioningConfiguration: { status: "Enabled" },
414
+ }, { parent: this });
415
+ }
416
+
417
+ // Encryption on by default
418
+ if (args.enableEncryption !== false) {
419
+ new aws.s3.BucketServerSideEncryptionConfigurationV2(`${name}-encryption`, {
420
+ bucket: bucket.id,
421
+ rules: [{ applyServerSideEncryptionByDefault: { sseAlgorithm: "AES256" } }],
422
+ }, { parent: this });
423
+ }
424
+
425
+ // Public access blocked by default
426
+ if (args.blockPublicAccess !== false) {
427
+ new aws.s3.BucketPublicAccessBlock(`${name}-public-access`, {
428
+ bucket: bucket.id,
429
+ blockPublicAcls: true,
430
+ blockPublicPolicy: true,
431
+ ignorePublicAcls: true,
432
+ restrictPublicBuckets: true,
433
+ }, { parent: this });
434
+ }
435
+
436
+ this.bucketId = bucket.id;
437
+ this.arn = bucket.arn;
438
+ this.registerOutputs({ bucketId: this.bucketId, arn: this.arn });
439
+ }
440
+ }
441
+ ```
442
+
443
+ ### Conditional Resource Creation
444
+
445
+ Use optional args to gate creation of sub-resources:
446
+
447
+ ```typescript
448
+ interface WebServiceArgs {
449
+ image: pulumi.Input<string>;
450
+ port: pulumi.Input<number>;
451
+ enableMonitoring?: pulumi.Input<boolean>;
452
+ alarmEmail?: pulumi.Input<string>;
453
+ }
454
+
455
+ class WebService extends pulumi.ComponentResource {
456
+ constructor(name: string, args: WebServiceArgs, opts?: pulumi.ComponentResourceOptions) {
457
+ super("myorg:index:WebService", name, {}, opts);
458
+
459
+ const service = new aws.ecs.Service(`${name}-service`, {
460
+ // ...service config...
461
+ }, { parent: this });
462
+
463
+ // Only create alarm infrastructure when monitoring is enabled
464
+ if (args.enableMonitoring) {
465
+ const topic = new aws.sns.Topic(`${name}-alerts`, {}, { parent: this });
466
+
467
+ if (args.alarmEmail) {
468
+ new aws.sns.TopicSubscription(`${name}-alert-email`, {
469
+ topic: topic.arn,
470
+ protocol: "email",
471
+ endpoint: args.alarmEmail,
472
+ }, { parent: this });
473
+ }
474
+
475
+ new aws.cloudwatch.MetricAlarm(`${name}-cpu-alarm`, {
476
+ // ...alarm config referencing service...
477
+ alarmActions: [topic.arn],
478
+ }, { parent: this });
479
+ }
480
+
481
+ this.registerOutputs({});
482
+ }
483
+ }
484
+ ```
485
+
486
+ ### Composition
487
+
488
+ Build higher-level components from lower-level ones. Each level manages a single concern.
489
+
490
+ ```typescript
491
+ // Lower-level component
492
+ class VpcNetwork extends pulumi.ComponentResource {
493
+ public readonly vpcId: pulumi.Output<string>;
494
+ public readonly publicSubnetIds: pulumi.Output<string>[];
495
+ public readonly privateSubnetIds: pulumi.Output<string>[];
496
+
497
+ constructor(name: string, args: VpcNetworkArgs, opts?: pulumi.ComponentResourceOptions) {
498
+ super("myorg:index:VpcNetwork", name, {}, opts);
499
+ // ...create VPC, subnets, route tables...
500
+ this.registerOutputs({ vpcId: this.vpcId });
501
+ }
502
+ }
503
+
504
+ // Higher-level component that uses VpcNetwork
505
+ class Platform extends pulumi.ComponentResource {
506
+ public readonly kubeconfig: pulumi.Output<string>;
507
+
508
+ constructor(name: string, args: PlatformArgs, opts?: pulumi.ComponentResourceOptions) {
509
+ super("myorg:index:Platform", name, {}, opts);
510
+
511
+ // Compose lower-level components
512
+ const network = new VpcNetwork(`${name}-network`, {
513
+ cidrBlock: args.cidrBlock,
514
+ }, { parent: this });
515
+
516
+ const cluster = new aws.eks.Cluster(`${name}-cluster`, {
517
+ vpcConfig: {
518
+ subnetIds: network.privateSubnetIds,
519
+ },
520
+ }, { parent: this });
521
+
522
+ this.kubeconfig = cluster.kubeconfig;
523
+ this.registerOutputs({ kubeconfig: this.kubeconfig });
524
+ }
525
+ }
526
+ ```
527
+
528
+ ### Provider Passthrough
529
+
530
+ Accept explicit providers for multi-region or multi-account deployments. `ComponentResourceOptions` carries provider configuration to children automatically:
531
+
532
+ ```typescript
533
+ // Consumer passes a provider for a different region
534
+ const usWest = new aws.Provider("us-west", { region: "us-west-2" });
535
+ const site = new StaticSite("west-site", { indexDocument: "index.html" }, {
536
+ providers: [usWest],
537
+ });
538
+ ```
539
+
540
+ Children with `{ parent: this }` automatically inherit the provider. No extra code is needed inside the component.
541
+
542
+ ---
543
+
544
+ ## Multi-Language Components
545
+
546
+ If your component will be consumed from multiple Pulumi languages (TypeScript, Python, Go, C#, Java, YAML), package it as a multi-language component.
547
+
548
+ ### Do You Need Multi-Language?
549
+
550
+ Ask: "Will anyone consume this component from a different language than it was authored in?"
551
+
552
+ **Single-language component** (no packaging needed):
553
+
554
+ - Your team uses one language and the component stays within that codebase
555
+ - The component is internal to a single project or monorepo
556
+ - No `PulumiPlugin.yaml` needed -- just import the class directly
557
+
558
+ **Multi-language component** (packaging required):
559
+
560
+ - Other teams consume your component in different languages
561
+ - Platform teams building abstractions for developers who choose their own language
562
+ - YAML consumers need access -- even if you author in TypeScript, YAML programs require multi-language packaging to use your component
563
+ - Building a shared component library for your organization
564
+ - Publishing to the Pulumi private registry or public registry is a common reason, but not required for multi-language support
565
+
566
+ **Common mistake**: A TypeScript platform team builds components only their TypeScript users can consume. If application developers use Python or YAML, those components are invisible to them without multi-language packaging.
567
+
568
+ ### Setup
569
+
570
+ Create a `PulumiPlugin.yaml` in the component directory to declare the runtime:
571
+
572
+ ```yaml
573
+ runtime: nodejs
574
+ ```
575
+
576
+ Or for Python:
577
+
578
+ ```yaml
579
+ runtime: python
580
+ ```
581
+
582
+ ### Serialization Constraints
583
+
584
+ For multi-language compatibility, args must be serializable. These constraints apply regardless of the authoring language:
585
+
586
+ | Allowed | Not Allowed |
587
+ |---------|-------------|
588
+ | `string`, `number`, `boolean` | Union types (`string \| number`) |
589
+ | `Input<T>` wrappers | Functions and callbacks |
590
+ | Arrays and maps of primitives | Complex nested generics |
591
+ | Enums | Platform-specific types |
592
+
593
+ ### Consuming Multi-Language Components
594
+
595
+ Consumers install the component with `pulumi package add`, which automatically downloads the provider plugin, generates a local SDK in the consumer's language, and updates `Pulumi.yaml`:
596
+
597
+ ```bash
598
+ # From a Git repository
599
+ pulumi package add <git-repo-url>
600
+
601
+ # From a specific version tag
602
+ pulumi package add <git-repo-url>@v1.0.0
603
+ ```
604
+
605
+ For fresh checkouts or CI environments, run `pulumi install` to ensure all package dependencies are available. The consumer does not need to manually generate SDKs.
606
+
607
+ Authors who publish SDKs to package managers (npm, PyPI, etc.) can optionally use `pulumi package gen-sdk` to generate language-specific SDKs for publishing. Most component authors do not need this -- `pulumi package add` handles SDK generation on the consumer side.
608
+
609
+ ### Entry Points
610
+
611
+ Published multi-language components require an entry point that hosts the component provider process. The entry point pattern differs by language.
612
+
613
+ **TypeScript** (`runtime: nodejs`):
614
+
615
+ Export component classes from `index.ts`. No separate entry point file is needed. Pulumi introspects exported classes automatically.
616
+
617
+ ```typescript
618
+ // index.ts -- exports are the entry point
619
+ export { StaticSite, StaticSiteArgs } from "./staticSite";
620
+ export { SecureBucket, SecureBucketArgs } from "./secureBucket";
621
+ ```
622
+
623
+ **Python** (`runtime: python`):
624
+
625
+ Create a `__main__.py` that calls `component_provider_host` with all component classes:
626
+
627
+ ```python
628
+ from pulumi.provider.experimental import component_provider_host
629
+ from static_site import StaticSite
630
+ from secure_bucket import SecureBucket
631
+
632
+ if __name__ == "__main__":
633
+ component_provider_host(
634
+ name="my-components",
635
+ components=[StaticSite, SecureBucket],
636
+ )
637
+ ```
638
+
639
+ **Go** (`runtime: go`):
640
+
641
+ Create a `main.go` that builds and runs the provider:
642
+
643
+ ```go
644
+ package main
645
+
646
+ import (
647
+ "context"
648
+ "fmt"
649
+ "os"
650
+
651
+ "github.com/pulumi/pulumi-go-provider/infer"
652
+ )
653
+
654
+ func main() {
655
+ p, err := infer.NewProviderBuilder().
656
+ WithComponents(
657
+ infer.ComponentF(NewStaticSite),
658
+ infer.ComponentF(NewSecureBucket),
659
+ ).
660
+ Build()
661
+ if err != nil {
662
+ fmt.Fprintln(os.Stderr, err)
663
+ os.Exit(1)
664
+ }
665
+ if err := p.Run(context.Background(), "my-components", "0.1.0"); err != nil {
666
+ fmt.Fprintln(os.Stderr, err)
667
+ os.Exit(1)
668
+ }
669
+ }
670
+ ```
671
+
672
+ **C#** (`runtime: dotnet`):
673
+
674
+ Create a `Program.cs` that serves the component provider host:
675
+
676
+ ```csharp
677
+ using System.Threading.Tasks;
678
+
679
+ class Program
680
+ {
681
+ public static Task Main(string[] args) =>
682
+ Pulumi.Experimental.Provider.ComponentProviderHost.Serve(args);
683
+ }
684
+ ```
685
+
686
+ For a complete working example across all languages, see https://github.com/mikhailshilkov/comp-as-comp.
687
+
688
+ **Reference**: https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/
689
+
690
+ ---
691
+
692
+ ## Distribution
693
+
694
+ Choose a distribution method based on your audience:
695
+
696
+ | Audience | Method | How |
697
+ |----------|--------|-----|
698
+ | Same project | Direct import | Standard language import |
699
+ | Same organization | Private registry | `pulumi package publish` to Pulumi Cloud |
700
+ | Same organization | Git repository | `pulumi package add <repo>` with version tags |
701
+ | Language ecosystem | Package manager | Publish to npm, PyPI, NuGet, or Maven |
702
+ | Public community | Pulumi Registry | Submit via pulumi/registry GitHub repo |
703
+
704
+ ### Pulumi Private Registry
705
+
706
+ The private registry is the centralized catalog for your organization's components. It provides automatic API documentation, version management, and discoverability for all teams.
707
+
708
+ Publish a component to the private registry:
709
+
710
+ ```bash
711
+ pulumi package publish https://github.com/myorg/my-component --publisher myorg
712
+ ```
713
+
714
+ Version components using git tags with a `v` prefix:
715
+
716
+ ```bash
717
+ git tag v1.0.0
718
+ git push origin v1.0.0
719
+ ```
720
+
721
+ A README file is required when publishing. Pulumi uses it as the component's documentation page in the registry.
722
+
723
+ Automate publishing from GitHub Actions using OIDC authentication:
724
+
725
+ ```yaml
726
+ name: Publish Component
727
+ on:
728
+ push:
729
+ tags:
730
+ - "v*"
731
+
732
+ permissions:
733
+ id-token: write
734
+ contents: read
735
+
736
+ jobs:
737
+ publish:
738
+ runs-on: ubuntu-latest
739
+ env:
740
+ PULUMI_ORG: myorg
741
+ steps:
742
+ - uses: actions/checkout@v4
743
+ with:
744
+ fetch-depth: 0
745
+ - uses: pulumi/auth-actions@v1
746
+ with:
747
+ organization: ${{ env.PULUMI_ORG }}
748
+ requested-token-type: urn:pulumi:token-type:access_token:organization
749
+ - run: pulumi package publish https://github.com/${{ github.repository }} --publisher ${{ env.PULUMI_ORG }}
750
+ ```
751
+
752
+ **Prerequisites**: Configure GitHub OIDC integration with Pulumi Cloud before using this workflow.
753
+
754
+ The registry supports private GitHub and GitLab repositories. For non-OIDC setups, authenticate with `GITHUB_TOKEN` or `GITLAB_TOKEN` environment variables.
755
+
756
+ The private registry automatically generates SDK documentation for each published component. Enrich the generated docs by adding type annotations to your component's inputs and outputs (JSDoc in TypeScript, docstrings in Python, `Annotate()` methods in Go).
757
+
758
+ **Reference**: https://www.pulumi.com/docs/idp/get-started/private-registry/
759
+
760
+ ### Git Repository Distribution
761
+
762
+ Tag releases for consumers to pin versions:
763
+
764
+ ```bash
765
+ git tag v1.0.0
766
+ git push origin v1.0.0
767
+ ```
768
+
769
+ Consumers install with:
770
+
771
+ ```bash
772
+ pulumi package add https://github.com/myorg/my-component@v1.0.0
773
+ ```
774
+
775
+ ### Package Manager Distribution
776
+
777
+ Publish language-specific packages for native dependency management:
778
+
779
+ - **npm**: `npm publish` for TypeScript/JavaScript
780
+ - **PyPI**: `twine upload` for Python
781
+ - **NuGet**: `dotnet nuget push` for .NET
782
+ - **Maven Central**: Standard Maven publishing for Java
783
+
784
+ **Reference**: https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/
785
+
786
+ ---
787
+
788
+ ## Anti-Patterns
789
+
790
+ | Anti-Pattern | Problem | Fix |
791
+ |-------------|---------|-----|
792
+ | Resources inside `apply()` | Not visible in `pulumi preview` | Move resource creation outside apply (see `pulumi-best-practices` practice 1) |
793
+ | Missing `registerOutputs()` | Component stuck "creating" | Always call as last line of constructor |
794
+ | Missing `parent: this` | Children appear at root level | Pass `{ parent: this }` to all child resources |
795
+ | Union types in args | Breaks Python, Go, C# SDKs | Use single types; separate properties for variants |
796
+ | Functions in args | Cannot serialize across languages | Use configuration properties instead |
797
+ | Hardcoded child names | Collisions with multiple instances | Derive names from `${name}-suffix` |
798
+ | Over-exposed outputs | Leaks implementation details | Export only what consumers need |
799
+ | Single-use component | Unnecessary abstraction overhead | Use inline resources until a pattern repeats |
800
+ | Deeply nested args | Hard to use and evolve | Keep interfaces flat with optional properties |
801
+
802
+ ---
803
+
804
+ ## Quick Reference
805
+
806
+ | Topic | Key Point |
807
+ |-------|-----------|
808
+ | Type URN | `<package>:<module>:<type>`, module usually `index` |
809
+ | Constructor | `super(type, name, {}, opts)` then children then `registerOutputs()` |
810
+ | Child resources | Always `{ parent: this }`, derive name from `${name}-suffix` |
811
+ | Args interface | Wrap in `Input<T>`, no unions, no functions, flat structure |
812
+ | Outputs | Public readonly `Output<T>` properties, expose only essentials |
813
+ | Defaults | Use `??` operator to apply sensible defaults in constructor |
814
+ | Composition | Lower-level components composed into higher-level ones |
815
+ | Multi-language | `PulumiPlugin.yaml` + entry point; consumers use `pulumi package add` |
816
+ | Distribution | Private registry, git tags, package managers, or public Pulumi Registry |
817
+
818
+ ## Related Skills
819
+
820
+ - **pulumi-best-practices**: General Pulumi patterns including Output handling, secrets, and aliases
821
+ - **pulumi-automation-api**: Programmatic orchestration for integration testing and multi-stack workflows
822
+ - **pulumi-esc**: Centralized secrets and configuration for component deployments
823
+
824
+ ## References
825
+
826
+ - https://www.pulumi.com/docs/iac/concepts/resources/components/
827
+ - https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/
828
+ - https://www.pulumi.com/docs/idp/get-started/private-registry/
829
+ - https://www.pulumi.com/docs/iac/concepts/inputs-outputs/
830
+ - https://www.pulumi.com/docs/iac/concepts/resources/options/aliases/