The Complete Production SOP: How to Deploy and Run Pulumi TypeScript Infrastructure as Code & ComponentResources in Autonomous AI Agents
Step-by-step SOP to install & run Pulumi TypeScript IaC & ComponentResources in Codex, Claude Code, and Cursor. Verified prompts, Jest tests, and fixes.
Technical Overview & Architectural Context
Autonomous coding agents frequently encounter critical failures when authoring Pulumi TypeScript infrastructure. Common regressions include treating Pulumi Outputs like standard synchronous TypeScript promises (e.g., using await instead of .apply() or pulumi.interpolate), instantiating cloud resources inside component constructors without properly passing custom ResourceOptions parent references, and forgetting to register stack outputs via export. When an LLM generates unconstrained infrastructure scripts, it risks creating orphaned resources, generating circular dependency graphs in the engine DAG, or leaking unencrypted credentials directly into declarative source files. The pulumi-typescript-iac skill imposes strict procedural rules that instruct agents like Claude Code, Codex, and Cursor to handle Pulumi constructs deterministically. It enforces proper typing across @pulumi/pulumi, establishes structured subclass patterns for pulumi.ComponentResource, mandates local syntax and unit test verification (using Mocha/Jest and Pulumi runtime mocks), and establishes explicit boundaries for previews and applying state.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Skill Manifest Mounting for Agent Runtimes
Mount the SKILL.md definition into the local agent workspace skill registry.
Autonomous agents discover domain skills by traversing workspace metadata and root rule folders (.cursor/rules, .claude/skills, or global agent directories). Mounting the SKILL.md under your active project guarantees that natural language triggers such as 'build pulumi componentresource' or 'create pulumi typescript stack' activate the exact SOP rather than generic model hallucinations.
mkdir -p .agents/skills/pulumi-typescript-iac && curl -fsSL https://askills.dev/api/skills/pulumi-typescript-iac/raw -o .agents/skills/pulumi-typescript-iac/SKILL.md---
name: "pulumi-typescript-iac"
description: "Define cloud infrastructure using real programming languages (TypeScript) and type safety."
metadata:
author: "Pulumi"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "create pulumi typescript stack"
- "build pulumi componentresource"
- "test pulumi iac jest"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---In Claude Code or Cursor, create a symbolic link from .agents/skills/pulumi-typescript-iac/SKILL.md to .cursorrules or CLAUDE.md to preserve runtime context tokens while maintaining uniform SOP across both tools.
Ensure permissions in SKILL.md respect sandbox security. shell_exec is set to false in the frontmatter by default; executing pulumi preview requires the user to explicitly grant CLI execution in the agent shell prompt.
TypeScript Environment and Pulumi SDK Initialization
Install core Pulumi packages and configure strict TypeScript compiler options.
Agents must write code against modern Pulumi typing definitions. Configure tsconfig.json with strict type checks to ensure the agent resolves Pulumi Output<T> vs Input<T> mismatches during build time instead of triggering runtime deployment crashes.
npm install @pulumi/pulumi @pulumi/aws && npm install --save-dev typescript @types/node jest ts-jest @types/jest{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*.ts", "tests/**/*.ts", "index.ts"]
}Direct the agent to reference Pulumi types via pulumi.Input<string> instead of raw string in resource argument interfaces to allow transparent resolution of dependent outputs.
Never expose cloud provider access keys inside Pulumi.yaml, Pulumi.<stack>.yaml, or prompt logs. Rely on environment variable injection (e.g., AWS_PROFILE or AWS_DEFAULT_REGION) or Pulumi ESC (Environments, Secrets, and Configuration).
Triggering Deterministic ComponentResource Construction
Prompt the agent using verified trigger phrases to scaffold a robust ComponentResource.
The skill enforces extending pulumi.ComponentResource, correctly passing the parent ResourceOptions { parent: this } to child resources, and invoking this.registerOutputs() upon completion. This ensures accurate dependency graph construction and prevents orphaned state.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
export interface SecureBucketArgs {
bucketPrefix: pulumi.Input<string>;
enableVersioning?: boolean;
}
export class SecureBucket extends pulumi.ComponentResource {
public readonly bucketName: pulumi.Output<string>;
public readonly arn: pulumi.Output<string>;
constructor(name: string, args: SecureBucketArgs, opts?: pulumi.ComponentResourceOptions) {
super("custom:storage:SecureBucket", name, {}, opts);
const bucket = new aws.s3.BucketV2(`${name}-bucket`, {
bucketPrefix: args.bucketPrefix,
}, { parent: this });
new aws.s3.BucketServerSideEncryptionConfigurationV2(`${name}-sse`, {
bucket: bucket.id,
rules: [{
applyServerSideEncryptionByDefault: {
sseAlgorithm: "AES256",
},
}],
}, { parent: this });
this.bucketName = bucket.id;
this.arn = bucket.arn;
this.registerOutputs({
bucketName: this.bucketName,
arn: this.arn,
});
}
}Instruct the agent to prefix custom ComponentResource types with an organizational domain (e.g., 'custom:storage:SecureBucket') to prevent naming conflicts in Pulumi Cloud state graphs.
Omitting { parent: this } in sub-resource declarations causes child resources to detach from the parent ComponentResource in the Pulumi URN hierarchy, breaking cascading deletion and IAM tagging policies.
Offline Unit Testing and Quality Gate Verification
Run deterministic unit tests using Pulumi runtime mocks before previewing cloud changes.
Autonomous agents should never attempt live infrastructure deployment without first passing deterministic mocking tests. Setting up pulumi.runtime.setMocks allows Jest to assert resource properties, tags, and security invariants locally in milliseconds without initiating AWS API calls.
npx jest --verboseimport * as pulumi from "@pulumi/pulumi";
pulumi.runtime.setMocks({
newResource: (args: pulumi.runtime.MockResourceArgs): { id: string; state: any } => {
return { id: `${args.name}-mock-id`, state: args.inputs };
},
call: (args: pulumi.runtime.MockCallArgs) => args.inputs,
});
describe("SecureBucket ComponentResource", () => {
it("configures default server-side encryption", async () => {
const { SecureBucket } = await import("../src/secureBucket");
const instance = new SecureBucket("test-bucket", { bucketPrefix: "logs-" });
instance.bucketName.apply(name => {
expect(name).toBeDefined();
});
});
});Run 'npx tsc --noEmit' alongside Jest within agent verification checks to catch Output<T> / Input<T> mismatches before previewing.
Dynamic imports (await import(...)) must be used in Jest tests when initializing Pulumi resources to guarantee that pulumi.runtime.setMocks is registered prior to resource module evaluation.
Real-World Scenario: Author a Reusable ComponentResource for Static Web Hosting with Unit Tests
“Using pulumi-typescript-iac, build a pulumi componentresource called StaticSite that creates an AWS S3 bucket with website configuration, public read policy, and a CloudFront distribution. Include a Jest test verifying encryption and export the CloudFront domain name.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent attempted standard JavaScript string concatenation (`https://${bucket.websiteEndpoint}`) or called .toString() on a Pulumi Output instance instead of resolving the deferred async value.
// Incorrect: const url = `https://${bucket.websiteEndpoint}`;
// Correct Fix:
import * as pulumi from "@pulumi/pulumi";
export const url = pulumi.interpolate`https://${bucket.websiteEndpoint}`;Root Cause: The agent misconfigured ResourceOptions parent references by assigning a standard CustomResource as a parent to another CustomResource rather than attaching them to the root ComponentResource.
// Inside ComponentResource constructor:
// Fix: Ensure opts parent points to 'this' (the ComponentResource), not another leaf resource:
const bucket = new aws.s3.BucketV2("app-assets", {}, { parent: this });
const sse = new aws.s3.BucketServerSideEncryptionConfigurationV2("app-sse", {
bucket: bucket.id,
}, { parent: this }); // Correct parent assignmentFrequently Asked Questions (Pulumi TypeScript Infrastructure as Code & ComponentResources SOP)
Q:Can I use Pulumi TypeScript Infrastructure as Code & ComponentResources across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification. Its structured frontmatter triggers and SOP guidelines are natively loaded by Codex CLI, Claude Code, Cursor Composer, and Windsurf Cascade without runtime-specific changes.
Q:How does Pulumi TypeScript Infrastructure as Code & ComponentResources prevent context window overflow during long agent sessions?
The skill provides procedural SOPs and mock patterns rather than exhaustive Cloud Provider API documentation. By directing agents to rely on TypeScript compilation errors (tsc --noEmit) and Jest unit tests, the agent iterates deterministically via shell output rather than inflating context with repetitive prompts.
Q:Does this skill require escalated root or container permissions?
No. The skill is audited with a security score of 98/100. It requires standard workspace file access (fs_read: true, fs_write: workspace) and keeps shell_exec off by default, ensuring all generated TypeScript IaC can be inspected before deployment.
Ready to equip your autonomous agent with Pulumi TypeScript Infrastructure as Code & ComponentResources?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.