Conversation
Flip enable_cdn = true in all three env tfvars (dev, staging, prod).
The compute.tf local already derives lambda_function_url_auth_type =
"AWS_IAM" when enable_cdn = true, and frontend.tf sets enable_oac =
true for the Lambda compute path, so a single flag flip activates:
- aws_cloudfront_origin_access_control.lambda (sigv4, always-sign)
- aws_lambda_function_url.main auth_type NONE -> AWS_IAM
- aws_lambda_permission.function_url_cloudfront scoped to the
distribution ARN
Dev: remove raw Lambda Function URL from lambda_allowed_origins (now
behind CloudFront); add post-apply note to set the CF domain.
Staging/prod: keep .invalid placeholders (envs not provisioned yet);
replace TODO with explicit pre-apply checklist.
terraform validate: Success. terraform fmt -check: clean (all envs).
terraform plan (dev only): 7 to add, 3 to change, 4 to destroy
(the 4 destroys are docker_build/cleanup terraform_data replaces
triggered by the placeholder image URI, unrelated to OAC).
Closes #575
|
Warning Review limit reached
More reviews will be available in 47 minutes and 44 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
Rate Limit Exceeded
|
Summary
enable_cdn = falsetoenable_cdn = truein all three env tfvars (dev, staging, prod), activating the CloudFront OAC chain and AWS_IAM auth on the Lambda Function URL that was scaffolded in PR sec(iac): Lambda Function URL auth hardening -- CORS wildcard rejection + AWS_IAM OAC scaffolding (#390, #424) #574 but left gated behind TODO comments.lambda_allowed_origins(it will be unreachable directly onceauth_type = AWS_IAM); add post-apply note to set the CloudFront domain after first apply.What flips, in what order
A single
enable_cdn = truein each tfvars activates three resources atomically in oneterraform apply:aws_cloudfront_origin_access_control.lambda-- OAC of typelambda, SigV4always-sign, created by the frontend module whenenable_oac = true(set automatically fromenable_cdn && compute_platform == "lambda"infrontend.tf).aws_cloudfront_distribution.frontend-- CloudFront distribution with the OAC attached to the Lambda Function URL origin.aws_lambda_permission.function_url_cloudfront-- permission scopinglambda:InvokeFunctionUrlto the distribution ARN (environment layer,compute.tf).aws_lambda_function_url.mainauth_type:NONE->AWS_IAM(derived fromlocal.lambda_function_url_auth_type = var.enable_cdn ? "AWS_IAM" : "NONE"incompute.tf).Deploy order: dev first. Staging and prod are not provisioned yet (
.invalidplaceholder origins); theirenable_cdn = trueis committed here so they go straight to OAC-enabled when provisioned, but no apply risk until a real environment exists.File-by-file changes
terraform/environments/aws/github-dev.tfvarsenable_cdn = true; remove raw Lambda URL fromlambda_allowed_origins; add post-apply note to add CF domainterraform/environments/aws/github-staging.tfvarsenable_cdn = true; replace TODO with pre-apply checklist (staging not provisioned)terraform/environments/aws/github-prod.tfvarsenable_cdn = true; replace TODO with pre-apply checklist (prod not provisioned)No module changes -- the scaffolding (OAC resource,
enable_oacvariable,aws_lambda_permission, auth_type local) was fully landed in PR #574.Verified outputs
terraform fmt -check(all envs, single config root)terraform validate(all envs, single config root)terraform plan(DEV only -- account 909626172446, profile cristi-cloudprowess-prd)Plan: 7 to add, 3 to change, 4 to destroy
Resources added (OAC chain):
aws_lambda_permission.function_url_cloudfront[0]module.frontend[0].aws_cloudfront_distribution.frontendmodule.frontend[0].aws_cloudfront_function.security_headersmodule.frontend[0].aws_cloudfront_origin_access_control.lambda[0]module.frontend[0].aws_cloudwatch_metric_alarm.cloudfront_5xxResources changed:
module.compute_lambda[0].aws_lambda_function.main-- CORS origins update, env var changesmodule.compute_lambda[0].aws_lambda_function_url.main-- auth_type:NONE->AWS_IAMmodule.build[0].terraform_data.image_tag-- placeholder image URI triggers tag recalculation (expected; CI provides real URI)Resources destroyed (4 = 2 replacements x destroy+create):
module.build[0].terraform_data.docker_build[0]andmodule.build[0].terraform_data.docker_cleanup[0]-- these areterraform_databuild triggers that replace when image URI changes; unrelated to OAC and expected when running plan with a placeholder URI outside CI.No unexpected resource churn. The Lambda URL itself is an in-place update (auth_type change), not a replacement.
Risk callouts
https://33pz7pombdqwu3bdlxp4lqxyra0bsriy.lambda-url.us-east-1.on.aws) will return HTTP 403 for direct requests after apply -- this is the intended security posture. All traffic must go through CloudFront.lambda_allowed_originsuses.invalidTLD placeholders; any accidentalterraform applywill fail fast on hostname resolution before touching live resources. Update to real CF domains before provisioning these envs.terraform applywill block until the distribution isDeployed. Plan for this in maintenance windows.lambda_allowed_originsfor dev is now["http://localhost:3000"]only. After apply, runterraform output cloudfront_domain_nameand add that value tolambda_allowed_origins, then re-apply so CORS allows the CF origin. Without this second apply, browser requests from the CF domain will be rejected by Lambda's CORS policy (CORS is enforced at the app layer, separate from the IAM gate).Roll-back plan
If the cut-over breaks something post-merge:
github-dev.tfvars, setenable_cdn = falseand restore the Lambda Function URL inlambda_allowed_origins.terraform apply-- this destroys the CloudFront distribution and OAC, and flipsauth_typeback toNONE.No data migrations involved; roll-back is safe at any time.
Manual verification steps (post-deploy)
terraform apply -var-file=github-dev.tfvarscompletes successfully.terraform output cloudfront_domain_name-- note the*.cloudfront.netdomain.curl -I https://<cloudfront-domain>/health-- expectHTTP/2 200.curl -I https://33pz7pombdqwu3bdlxp4lqxyra0bsriy.lambda-url.us-east-1.on.aws/health-- expectHTTP/2 403(Lambda URL now IAM-gated).lambda_allowed_originsingithub-dev.tfvarsand re-apply to fix CORS for browser fetch calls.Closes LeanerCloud/cloud-commitments-platform#16
Refs #424