Skip to content

fix(operator): Support private VPC S3 endpoints in endpoint validation#22395

Open
ptux wants to merge 1 commit into
grafana:mainfrom
ptux:fix/operator-vpc-s3-endpoint
Open

fix(operator): Support private VPC S3 endpoints in endpoint validation#22395
ptux wants to merge 1 commit into
grafana:mainfrom
ptux:fix/operator-vpc-s3-endpoint

Conversation

@ptux

@ptux ptux commented Jun 12, 2026

Copy link
Copy Markdown

Summary

  • Add regex-based validation for AWS VPC S3 endpoints (https://vpce-{id}.s3.{region}.vpce.amazonaws.com) to validateS3Endpoint()
  • Reject bucket-prefixed endpoints to prevent unintended folder creation in S3 buckets
  • Provide specific error messages for region mismatches and invalid formats

Context

This is a clean rewrite of #19247 (originally by @puretension with review contributions from @JoaoBraveCoding) which had been open for 9 months. The original PR had a test bug (expected scheme-prefixed endpoint in ForcePathStyle test while extractS3ConfigSecret strips the scheme) and accumulated 11 commits including merge commits.

This PR squashes everything into a single commit with the test bug fixed.

Fixes #19243

Changes

operator/internal/handlers/internal/storage/secrets.go:

  • Add compiled regex patterns for standard S3, VPC, and bucket-prefixed endpoint formats
  • Rewrite validateS3Endpoint() to validate using regex matching with region extraction
  • Add errS3EndpointAWSNoRegion and errS3EndpointNoBucketName error variables

operator/internal/handlers/internal/storage/secrets_test.go:

  • Add test cases: valid VPC endpoint, bucket-prefixed VPC endpoint rejection, wrong region VPC endpoint
  • Add ForcePathStyle test for VPC endpoints verifying ForcePathStyle=false
  • Update existing error message assertions to match new validation output

Test plan

  • go test ./internal/handlers/internal/storage/... passes (all TestS3Extract* tests)
  • CI checks pass

Co-authored-by: puretension rlrlfhtm5@gmail.com
Co-authored-by: JoaoBraveCoding joao.coding@gmail.com

@cla-assistant

cla-assistant Bot commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Shuang Wang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

The operator's S3 endpoint validation was rejecting private VPC endpoints
(https://vpce-{id}.s3.{region}.vpce.amazonaws.com) because it only accepted
the standard format (https://s3.{region}.amazonaws.com).

This updates validateS3Endpoint to use regex-based validation that:
- Accepts standard AWS S3 endpoints with region verification
- Accepts VPC endpoints (vpce-*) with region verification
- Rejects bucket-prefixed endpoints to prevent folder creation issues
- Provides specific error messages for each failure case

Fixes grafana#19243
Co-authored-by: puretension <rlrlfhtm5@gmail.com>
Co-authored-by: JoaoBraveCoding <joao.coding@gmail.com>
@ptux ptux force-pushed the fix/operator-vpc-s3-endpoint branch from 73d98b3 to 0177abc Compare June 12, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inability to use a private VPC S3 endpoint with Loki

1 participant