feat: add cross-cloud CORS configuration for buckets#914
Open
tom-groves wants to merge 2 commits intonitrictech:mainfrom
Open
feat: add cross-cloud CORS configuration for buckets#914tom-groves wants to merge 2 commits intonitrictech:mainfrom
tom-groves wants to merge 2 commits intonitrictech:mainfrom
Conversation
Add CORS rule support to the Bucket deployment spec, with implementations across all providers (AWS, GCP, Azure) and both deployment paths (Pulumi, Terraform CDK). - Proto: add BucketCorsRule message with origins, methods, headers, expose headers, and max age fields - AWS: creates S3 BucketCorsConfigurationV2 (Pulumi) / aws_s3_bucket_cors_configuration (TF) - GCP: sets cors block on storage bucket; warns that AllowedHeaders is not supported by GCS (auto-allows all request headers) - Azure: returns error — per-container CORS not supported, must be configured at the Storage Account level - MaxAgeSeconds only emitted when > 0 to avoid overriding provider defaults (Pulumi path); always sent in TF path to satisfy HCL variable type requirements
Document CORS support in the main storage guide, including the per-provider behavior differences and limitations. Update AWS, GCP, and Azure provider mapping docs with CORS-specific details.
|
@tom-groves is attempting to deploy a commit to the Nitric Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add CORS rule support to the Bucket deployment spec, with full implementations across all three cloud providers (AWS, GCP, Azure) and both deployment paths (Pulumi, Terraform CDK).
This enables users to configure CORS rules on storage buckets as part of their Nitric deployment, with appropriate cross-cloud behavior:
BucketCorsConfigurationV2(Pulumi) /aws_s3_bucket_cors_configuration(Terraform)corsblock.AllowedHeadersis not supported by GCS (it auto-allows all request headers) — a warning is emitted when specified.Changes
Proto:
BucketCorsRulemessage withallowed_origins,allowed_methods,allowed_headers,expose_headers, andmax_age_secondsfieldsrepeated BucketCorsRule cors_rulesfield toBucketmessageAWS (Pulumi + Terraform CDK):
s3.BucketCorsConfigurationV2resource when CORS rules presentcors_rulesvariable andaws_s3_bucket_cors_configurationresource to HCL moduleGCP (Pulumi + Terraform CDK):
BucketCorArrayon bucket argscors_rulesvariable anddynamic "cors"block ongoogle_storage_bucketAllowedHeadersis specified (GCS does not support it)Azure (Pulumi + Terraform CDK):
Documentation:
docs/docs/storage.mdx)Design decisions
MaxAgeSecondsonly emitted when > 0 in Pulumi providers to avoid overriding cloud defaults. Always sent in TF wrappers to satisfy HCL variable type requirements.AllowedHeadersis a warning, not an error, because GCS behavior is a superset (allows all headers).Type of change
Testing
Build verification
All 6 deployment targets compile cleanly:
cloud/aws—go build ./deploy/...andgo build ./deploytf/...✓cloud/gcp—go build ./deploy/...andgo build ./deploytf/...✓cloud/azure—go build ./deploy/...andgo build ./deploytf/...✓Terraform module validation
terraform validatepasses for AWS bucket module (aws_s3_bucket_cors_configuration) ✓terraform validatepasses for GCP bucket module (google_storage_bucketcors block) ✓Pulumi mock tests (6 new tests — first deploy-level tests in this codebase)
AWS (3 tests):
TestBucket_WithCorsRules_CreatesS3CorsConfiguration— verifiesBucketCorsConfigurationV2resource created with correct field values (origins, methods, headers, expose headers, max age) ✓TestBucket_WithoutCorsRules_NoCorsConfiguration— verifies no CORS resource when rules absent ✓TestBucket_MultipleCorsRules— verifies single CORS config resource containing multiple rules ✓GCP (3 tests):
TestBucket_WithCorsRules_SetsCorsOnBucket— verifiescorsproperty set on bucket with correct field values (origins, methods, responseHeaders, maxAge) ✓TestBucket_WithoutCorsRules_NoCorsOnBucket— verifies nocorsproperty when rules absent ✓TestBucket_MultipleCorsRules— verifies 2 CORS rules on bucket ✓Regression
cloud/aws,cloud/gcp,cloud/azure,core,cloud/common) ✓cmd/failures in GCP/Azure (missing embedded runtime binary) are unrelated to this change