fix(aws): route the CD deploy payload through the authenticated s3:// fetch path - #2221
Conversation
… fetch path cd's fetchPayload only signs s3:// URIs, using the deploy container's ambient AWS credentials. The presigned upload URL, once stripped of its query string, is a bare virtual-hosted-style https:// URL, so cd's fetchHTTP did an unsigned GET and a private bucket 403'd it. Rewrite it to s3://bucket/key, mirroring the existing gs:// rewrite in gcp/byoc.go. Found while re-validating DefangLabs/pulumi-defang#423 (AWS CD image shell base + entrypoint fixes) against DefangLabs/defang-mvp#3181's new-provider-sanity smoketest.
|
Warning Review limit reached
Next review available in: 9 minutes Limit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
lionello
left a comment
There was a problem hiding this comment.
does this work for both old defang-mvp TS CD and the new pulumi-defang Golang CD?
|
Yes, works for both:
So this CLI-side rewrite is required for the new Go CD and harmless (pass-through) for the old TS CD. |
Four merges landed on main after the previous merge: #2225, #2226, #2224 (buildkit bump) and #2221. The conflicts were all dependency state, none in the cleanup code: - src/go.mod, src/go.sum: this branch carried AWS SDK pins from when it was opened in June, main has newer ones. Resolved to main's versions and re-ran `go mod tidy`, which re-added the ecr, elbv2 and rds modules this branch needs at their current versions. - pkgs/defang/cli.nix: took main's vendorHash as the closer starting point. The Update vendorHash step in go.yml corrects and commits it if the tidy moved it. src/pkg/cli/client/byoc/aws/byoc.go merged cleanly. `go build ./...` and `go test -short ./...` green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3WmpdY3zc555sNdkY9dzQ
Summary
cd'sfetchPayloadonly authenticatess3://URIs (via the deploy container's ambient AWS credentials, seefetchS3in pulumi-defang'scd/fetch.go). The AWS BYOC driver strips the query string off the presigned upload URL and passes the bare virtual-hosted-stylehttps://bucket.s3.region.amazonaws.com/keyURL tocd up. That routes throughfetchHTTP, which does a plain unsigned GET — a private bucket 403s it.This mirrors the
gs://rewrite already done for GCP ingcp/byoc.go(with the same comment: "Only gs:// is supported in the payload as http get in gcpcd does not handle auth yet"). AWS never got the equivalent rewrite.Context
Found while re-validating DefangLabs/pulumi-defang#423 (AWS CD image shell-base fix + defang#2217's entrypoint fix) against DefangLabs/defang-mvp#3181's
new-provider-sanitysmoketest. With those two fixes in place, the AWS leg now provisions and runs the correct entrypoint, but fails on this new blocker:I confirmed the CodeBuild task role (
defang-cd-TaskRole-*) hasPowerUserAccess, which includess3:GetObject— so a signed request throughfetchS3should succeed; the request is just never signed because it isn't recognized as an S3 URI.Change
Adds
s3PayloadURI, which rewritesbucket.s3.region.amazonaws.com/key(with or without a region segment) intos3://bucket/key; non-S3 URLs and base64 payloads pass through unchanged.Test plan
go test -short ./pkg/cli/client/byoc/aws/...passes, including newTestS3PayloadURIcases (regional URL, legacy no-region URL, non-S3 URL, base64 payload)golangci-lint run ./pkg/cli/client/byoc/aws/...— no new findings (4 pre-existing gosec findings, unrelated to this diff)new-provider-sanity.ymlwithaws-cli-versionpointed at this branch to confirm the AWS leg gets past the payload fetch