What the agent does
The agent reads the program before adding a resource to it. In a project like the aws-ts-s3-folder example in pulumi/examples, Pulumi.yaml names the project with runtime: nodejs and a template.config block declaring aws:region with a default of us-west-2; package.json is "type": "module" with @pulumi/aws 7.23.0, @pulumi/pulumi 3.228.0 and mime 4, and tsconfig.json compiles index.ts alone with module: nodenext, target: ES2022 and strict. index.ts creates an aws.s3.Bucket, an aws.s3.BucketWebsiteConfiguration with index.html as the index document, an aws.s3.BucketPublicAccessBlock with blockPublicAcls: false, one aws.s3.BucketObject per file in www/ (an index.html and a favicon.png) with the content type from mime, and an aws.s3.BucketPolicy that grants s3:GetObject to *, with dependsOn the access block. It exports bucketName and websiteUrl, the S3 website endpoint, which serves HTTP only. A sibling example, aws-ts-static-website, already fronts a bucket with CloudFront, but through an OriginAccessIdentity, a Route 53 zone and an ACM certificate, with redirect-to-https, PriceClass_100 and a custom 404 response.
It writes the CloudFront half with the current primitives rather than copying the sibling. An aws.cloudfront.OriginAccessControl with originAccessControlOriginType: "s3", signingBehavior: "always" and signingProtocol: "sigv4"; an aws.cloudfront.Distribution whose single origin is the bucket's bucketRegionalDomainName with that control's id, defaultRootObject: "index.html", a default cache behaviour with viewerProtocolPolicy: "redirect-to-https", GET, HEAD and OPTIONS only, and the managed CachingOptimized cache policy looked up with aws.cloudfront.getCachePolicy instead of hand-written TTLs; viewerCertificate: { cloudfrontDefaultCertificate: true } so the *.cloudfront.net name works with no domain; and priceClass read from a new priceClass config value that Pulumi.yaml's template block declares with a default of PriceClass_100, as the repository's contributing guide requires for any config the program reads.
Then it closes the bucket. The public BucketPolicy becomes one that allows s3:GetObject to the cloudfront.amazonaws.com service principal with a condition on AWS:SourceArn equal to the distribution's arn, the access block flips all four settings to true, and the BucketWebsiteConfiguration goes away, because the origin is now the REST endpoint. The websiteUrl export is replaced by cdnUrl, https:// and the distribution's domainName, and README.md's walkthrough, which prints websiteUrl and opens it, is updated to the new output and to the note that a distribution takes a few minutes to deploy. The bucketName export and the object loop over www/ stay as they are.
The sandbox has no AWS credentials and the agent does not ask for any, so pulumi preview is not something it can show. It verifies what it can: npm install and npx tsc --noEmit -p . on the strict config, and a mocha test written the way the repository's own testing-unit-ts/mocha/bucket_pair_test.ts does it, with pulumi.runtime.setMocks, asserting that the access block blocks public ACLs, that the policy's principal is the CloudFront service and not *, and that the distribution redirects to HTTPS. The test lives beside index.ts and runs with mocha -r ts-node/register. The repository's acceptance test TestAccAwsTsS3Folder in misc/test/performance_test.go deploys this example for real in the maintainers' CI, and the pull request names it as the step that proves the stack goes up.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Put CloudFront with HTTPS in front of the S3 website in this Pulumi TypeScript program and stop serving the bucket publicly. Read Pulumi.yaml, package.json, tsconfig.json, index.ts, the README and the www directory first, and look at any sibling program in the repository that already uses CloudFront, but use Origin Access Control rather than an origin access identity. Add an OriginAccessControl and a Distribution with the bucket's regional domain name as its only origin, index.html as the default root object, redirect-to-https, GET, HEAD and OPTIONS only, the managed CachingOptimized cache policy, the default CloudFront certificate, and a price class read from config with a default declared in Pulumi.yaml's template block. Replace the public bucket policy with one that allows GetObject to the CloudFront service principal conditioned on the distribution's ARN, block all public access, remove the website configuration, export the CloudFront URL instead of the website endpoint, and update the README. Run the TypeScript compiler in no-emit mode and write a mocha test with Pulumi mocks, modeled on the repository's own unit test example, that checks the access block, the policy principal and the HTTPS redirect. Say in the pull request that no preview or deployment was run.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request that edits index.ts, Pulumi.yaml, package.json and README.md and adds index_test.ts. The description shows the resource list the program now declares, the before and after of the bucket policy's principal, and the new priceClass config with its default, and says in one sentence that the sandbox compiled and unit-tested the program and did not run pulumi preview.
The run's record keeps the tsc --noEmit output and the mocha run with the three assertions, so a reviewer sees the program type-checks under strict and that the policy no longer names *. The pull request names the Go acceptance test that deploys this example in CI as the check that follows.
Before merging, a reviewer runs pulumi preview on a dev stack with their own credentials and reads the plan: one distribution and one origin access control created, the website configuration deleted, the access block and policy replaced in place. After pulumi up, curl -I on the cdnUrl output answers 200 over HTTPS and on the bucket's old website endpoint answers 403.
Run it on every Linear issue labelled infra
A team that plans infrastructure work in Linear adds an automation with a linear trigger on linear.issue.labeled for the label infra, the Project that has this repository, and this prompt. Labelling the issue that asks for HTTPS on the marketing site starts one run with the issue's text after the prompt, and the pull request links back to the issue.
The same automation serves the next infrastructure issue in the repository, such as a custom domain with an ACM certificate on the distribution, because the trigger adds whatever the issue says after the same prompt and the agent reads the program fresh each time.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
A CloudFront change touches the distribution, the bucket policy, the access block and the exports at once, and getting the principal or the SourceArn condition slightly wrong leaves the bucket either public or unreachable. The agent reads the real program in its own sandbox, makes the edits together, and type-checks and unit-tests them with the project's own tooling before a person spends a preview on it.
The pull request states what it proved and what it did not: compiled and tested, not deployed. A reviewer who runs the preview sees the exact resource plan the description predicts, and the run's record shows every command that led there.
Frequently asked questions
Why Origin Access Control instead of an origin access identity?
OAC is the current mechanism and supports SigV4 signing on every request, including to buckets with SSE-KMS. The sibling example in the repository uses the older identity, and the pull request notes the difference so a reader comparing the two is not confused.
Will the old website URL keep working?
No. Public access is blocked and the website configuration is removed, so the S3 website endpoint answers 403. That is the point of the change; anything that linked to the bucket endpoint moves to the cdnUrl output.
Can I add my own domain?
Yes, as a follow-up: an ACM certificate in us-east-1, aliases on the distribution and a Route 53 alias record. The aws-ts-static-website sibling shows the certificate validation dance, and the pull request points to it.
What does the agent run?
npm install, the TypeScript compiler in no-emit mode on the strict config, and a mocha test with Pulumi's mock runtime. It does not run pulumi preview or pulumi up, because the sandbox has no AWS credentials, and the description says so.
Does the content upload loop change?
No. Each file in www/ still becomes an aws.s3.BucketObject with its MIME type. Subdirectory index.html files are not resolved by CloudFront the way the S3 website endpoint did; the pull request says a CloudFront Function handles that if the site grows subdirectories.