-
-
Notifications
You must be signed in to change notification settings - Fork 311
Improve / Fix S3 Bucket Usage #2760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/nest-zappa-migration
Are you sure you want to change the base?
Improve / Fix S3 Bucket Usage #2760
Conversation
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughAdds hashicorp/random and random_id suffixes for unique bucket names; hardens state buckets with object lock, versioning, and prevent_destroy; switches staging backend to use a local terraform.tfbackend workflow and updates README; renames fixture/zappa bucket variables and removes force_destroy flags. (50 words) Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
infrastructure/README.md (1)
58-75: Staging backend-config instructions look correct; consider tiny clarification on regionThe new
terraform.tfbackendflow andterraform init -backend-config=terraform.tfbackendusage are consistent withstaging/backend.tfandterraform.tfbackend.example. To make it foolproof, you might add a short sentence that theregioninterraform.tfbackendmust match the region where the backend stack created the state bucket, so users don’t accidentally diverge configs.infrastructure/staging/terraform.tfbackend.example (1)
1-3: Backend example is correct; consider a more obvious placeholderThe example backend config matches the new staging workflow and the lock table name from the backend stack. To avoid users ever running with an invalid literal bucket name, you might consider changing
"${STATE_BUCKET_NAME}"to something obviously non-functional like"REPLACE_WITH_STATE_BUCKET_NAME"and/or adding a short comment in this file indicating it must be replaced with the backendstatebucket name.infrastructure/backend/main.tf (1)
74-82: Follow-up on Object Lock, MFA delete, and# NOSONARexpectations for the state bucketIssue #2759 calls out:
- Enabling S3 Object Lock for the state bucket.
- Enabling MFA delete on the state bucket.
- Resolving the
# NOSONARsuppressions on the bucket resources.In this module, the state bucket has versioning, lifecycle, encryption, and public access blocks, but there’s currently:
- No
object_lock_enabled/aws_s3_bucket_object_lock_configurationfor the state bucket.- No Terraform-visible configuration or documented manual step for MFA delete.
- The
# NOSONARcomments on thelogsandstatebuckets are still present.Given AWS and Terraform constraints, MFA delete typically has to be enabled manually using root credentials and the AWS CLI, with Terraform only reflecting the resulting state rather than enabling it directly. (rules.sonarsource.com)
Would you mind confirming how you plan to satisfy the issue requirements here?
- If Object Lock is in scope for this stack, we likely need to wire it explicitly on
aws_s3_bucket.state(and possibly add an object lock configuration resource).- For MFA delete, it may be better to document the manual post-
applystep and, if supported by the provider version, mirror the state back into Terraform after it’s enabled.- Once those concerns are addressed (either in code or as accepted limitations), we can probably remove or narrow the
# NOSONARsuppressions to avoid hiding future issues.Also applies to: 170-175
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
infrastructure/README.md(3 hunks)infrastructure/backend/.terraform.lock.hcl(1 hunks)infrastructure/backend/main.tf(3 hunks)infrastructure/staging/backend.tf(1 hunks)infrastructure/staging/terraform.tfbackend.example(1 hunks)infrastructure/staging/terraform.tfvars.example(1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2178
File: frontend/src/app/snapshots/[id]/page.tsx:0-0
Timestamp: 2025-09-21T17:04:48.154Z
Learning: User rudransh-shrivastava confirmed that suggested type safety improvements during Apollo Client migration were no longer relevant, reinforcing their preference to keep migration PRs focused on core migration changes rather than additional improvements.
📚 Learning: 2025-11-23T11:52:15.463Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2699
File: backend/wsgi.py:13-13
Timestamp: 2025-11-23T11:52:15.463Z
Learning: In the OWASP Nest project, the SSM parameter store setup in backend/wsgi.py (using boto3 to fetch parameters from AWS Systems Manager) is designed for staging and production environments, not just for testing purposes.
Applied to files:
infrastructure/staging/terraform.tfvars.exampleinfrastructure/staging/backend.tfinfrastructure/staging/terraform.tfbackend.example
📚 Learning: 2025-10-17T15:25:34.963Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/modules/cache/main.tf:30-30
Timestamp: 2025-10-17T15:25:34.963Z
Learning: The infrastructure/Terraform code in the OWASP Nest repository under the `infrastructure/` directory is intended for quick testing purposes only, not for production deployment.
Applied to files:
infrastructure/staging/terraform.tfvars.exampleinfrastructure/staging/terraform.tfbackend.exampleinfrastructure/README.md
📚 Learning: 2025-11-27T19:38:23.956Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2743
File: infrastructure/modules/storage/main.tf:1-9
Timestamp: 2025-11-27T19:38:23.956Z
Learning: In the OWASP/Nest infrastructure code (infrastructure/ directory), the team prefers exact version pinning for Terraform (e.g., "1.14.0") and AWS provider (e.g., "6.22.0") over semantic versioning constraints (e.g., "~> 1.14" or "~> 6.22"). This is a deliberate choice for maximum reproducibility and explicit control over version updates in their testing environment.
Applied to files:
infrastructure/backend/.terraform.lock.hclinfrastructure/staging/backend.tfinfrastructure/backend/main.tfinfrastructure/staging/terraform.tfbackend.example
📚 Learning: 2025-11-08T11:16:25.725Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2551
File: infrastructure/modules/parameters/main.tf:1-191
Timestamp: 2025-11-08T11:16:25.725Z
Learning: The parameters module in infrastructure/modules/parameters/ is currently configured for staging environment only. The `configuration` and `settings_module` variables default to "Staging" and "settings.staging" respectively, and users can update parameter values via the AWS Parameter Store console. The lifecycle.ignore_changes blocks on these parameters support manual console updates without Terraform reverting them.
Applied to files:
infrastructure/staging/terraform.tfbackend.example
📚 Learning: 2025-10-17T15:25:53.713Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/modules/database/main.tf:22-60
Timestamp: 2025-10-17T15:25:53.713Z
Learning: The infrastructure code in the `infrastructure/` directory is intended for quick testing purposes only, not production-grade deployment. Production-grade security hardening controls (such as IAM database authentication, deletion protection, Performance Insights KMS encryption) are not required for this testing infrastructure.
Applied to files:
infrastructure/README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Run frontend e2e tests
🔇 Additional comments (5)
infrastructure/backend/.terraform.lock.hcl (1)
27-45: Random provider lock entry looks consistent with main.tfThe
hashicorp/randomprovider pin (version and constraints both3.7.2) aligns withrequired_providersinmain.tfand with the repo's preference for exact pinning. No manual tweaks needed here.infrastructure/README.md (1)
25-40: Backend notes read clearly and match the new workflowThe added notes around optionally changing
aws_region, copying the state bucket name from outputs, and avoiding destroying backend resources clarify the one-time backend setup nicely and are aligned with how the backend stack is used.infrastructure/staging/terraform.tfvars.example (1)
9-9: Saferforce_destroy_bucketdefault is a good changeSetting
force_destroy_bucket = falseas the example default better protects against accidental bucket deletion, matching the intent from the linked issue.infrastructure/staging/backend.tf (1)
3-4: S3 backend simplification is consistent with the new backend-config flowLeaving only
encryptandkeyin thebackend "s3"block and moving bucket/region/lock table toterraform.tfbackendaligns with the documentedterraform init -backend-config=terraform.tfbackendworkflow. This looks good.infrastructure/backend/main.tf (1)
8-11: Random suffix integration into bucket names looks correctAdding the
hashicorp/randomprovider, definingrandom_id "suffix"withbyte_length = 4, and appendingrandom_id.suffix.hexto thelogsandstatebucket names is wired correctly. This should give you stable, per-workspace uniqueness for the backend buckets while keeping names predictable via theproject_nameprefix.Also applies to: 53-55, 75-76, 82-85
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
infrastructure/modules/storage/modules/s3-bucket/variables.tf (1)
18-22: Minor description wording adjustment. Changed from "Specifies the number of days..." to "The number of days..." — improves readability but note that other variable descriptions in the file still use "Specifies" (e.g., line 2), so consistency could be improved further.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
infrastructure/backend/main.tf(5 hunks)infrastructure/modules/ecs/main.tf(1 hunks)infrastructure/modules/ecs/variables.tf(1 hunks)infrastructure/modules/storage/main.tf(3 hunks)infrastructure/modules/storage/modules/s3-bucket/main.tf(1 hunks)infrastructure/modules/storage/modules/s3-bucket/variables.tf(1 hunks)infrastructure/modules/storage/variables.tf(2 hunks)infrastructure/staging/main.tf(2 hunks)infrastructure/staging/variables.tf(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2178
File: frontend/src/app/snapshots/[id]/page.tsx:0-0
Timestamp: 2025-09-21T17:04:48.154Z
Learning: User rudransh-shrivastava confirmed that suggested type safety improvements during Apollo Client migration were no longer relevant, reinforcing their preference to keep migration PRs focused on core migration changes rather than additional improvements.
📚 Learning: 2025-10-23T19:22:23.811Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/main.tf:0-0
Timestamp: 2025-10-23T19:22:23.811Z
Learning: In Zappa-based serverless deployments, Lambda functions and IAM execution roles are managed by Zappa at application deployment time (via `zappa deploy`/`zappa update`), not via Terraform. Terraform provisions the supporting infrastructure (VPC, RDS, S3, security groups, RDS Proxy, Secrets Manager), while Zappa handles the Lambda orchestration layer.
Applied to files:
infrastructure/modules/storage/variables.tfinfrastructure/staging/variables.tfinfrastructure/modules/storage/main.tf
📚 Learning: 2025-11-27T19:38:23.956Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2743
File: infrastructure/modules/storage/main.tf:1-9
Timestamp: 2025-11-27T19:38:23.956Z
Learning: In the OWASP/Nest infrastructure code (infrastructure/ directory), the team prefers exact version pinning for Terraform (e.g., "1.14.0") and AWS provider (e.g., "6.22.0") over semantic versioning constraints (e.g., "~> 1.14" or "~> 6.22"). This is a deliberate choice for maximum reproducibility and explicit control over version updates in their testing environment.
Applied to files:
infrastructure/modules/storage/main.tfinfrastructure/backend/main.tf
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Run backend tests
- GitHub Check: Run frontend e2e tests
- GitHub Check: Run frontend unit tests
- GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (18)
infrastructure/modules/ecs/variables.tf (1)
33-36: Variable rename aligns with consistent naming across infrastructure modules. Consistent with parallel renames ininfrastructure/modules/storage/variables.tfandinfrastructure/staging/variables.tf.infrastructure/backend/main.tf (6)
8-11: Random provider version pinning is consistent with infrastructure standards. Exact version3.7.2aligns with team's reproducibility preference (as per learnings on infrastructure versioning).Verify that
infrastructure/backend/.terraform.lock.hclincludes the random provider lock entry with version 3.7.2.
53-55: Random suffix approach ensures globally unique state bucket names. The 4-byte random hex suffix (16 million possible combinations) provides sufficient uniqueness to avoid S3 bucket name collisions across deployments.
75-75: Logs bucket now has accidental deletion protection and unique naming. Name is suffixed with random ID;prevent_destroylifecycle protects against unintended removal.Also applies to: 77-79
86-91: State bucket properly configured for durability and protection. Object lock enabled (object_lock_enabled = true), unique name via random suffix, and lifecycle protection against destruction align with PR objectives.
136-145: Object lock configuration protects state bucket from tampering. GOVERNANCE mode (vs. COMPLIANCE) is appropriate—allows authorized users to modify retention, preventing operational lock-in while still preventing accidental deletion. 30-day window provides reasonable protection window.
75-75: Verify that storage module buckets also implement random suffix for uniqueness. The backend state and logs buckets userandom_id.suffix.hex, but the storage module bucket naming pattern is not visible in this review. Confirm thatinfrastructure/modules/storage/main.tfimplements the same suffix pattern for fixtures and zappa buckets to prevent collisions across parallel deployments, as required by the PR objective to ensure uniqueness.infrastructure/modules/ecs/main.tf (1)
220-220: Variable reference updated consistently with rename. Updated fromfixtures_s3_buckettofixtures_bucket_name, aligning with the variable rename ininfrastructure/modules/ecs/variables.tf.infrastructure/modules/storage/modules/s3-bucket/main.tf (2)
38-38: Minor comment formatting improvement. Spacing adjusted for NOSONAR comment clarity; no functional impact.
43-45: Reusable s3-bucket module now includes destruction protection. Theprevent_destroylifecycle is applied at the module level, ensuring all buckets created via this module are protected from accidental removal. This extends the protection strategy beyond backend buckets to application buckets (fixtures, zappa).infrastructure/modules/storage/variables.tf (1)
12-15: Variable naming standardized across storage module. Renames (fixtures_s3_bucket→fixtures_bucket_nameandzappa_s3_bucket→zappa_bucket_name) improve consistency with naming conventions in backend and staging configurations.Also applies to: 28-30
infrastructure/staging/main.tf (1)
63-63: Module inputs updated consistently with variable renames. All three module invocations correctly reference the renamed variables:fixtures_bucket_nameandzappa_bucket_name.Also applies to: 112-112, 115-115
infrastructure/staging/variables.tf (2)
144-148: Zappa bucket default remains consistent.zappa_bucket_namedefault value unchanged at "owasp-nest-zappa-deployments"; aligns with parallel changes tofixtures_bucket_name.
90-94: Staging default bucket names should clarify testing-only scope or implement unique suffixes. Default forfixtures_bucket_namechanged from "nest-fixtures" to "owasp-nest-fixtures" (improved namespace, but static). Sinceinfrastructure/is designated for testing purposes only, confirm whether static defaults are intentional for this test environment or if parallel deployments require uniqueness guarantees. If production-like isolation is needed, verify thatinfrastructure/modules/storage/main.tfimplements random suffix logic similar to the backend pattern (backend/main.tf lines 53–55, 75, 86).infrastructure/modules/storage/main.tf (4)
8-11: Provider setup follows version pinning conventions.The random provider is correctly added with exact version pinning (3.7.2), which aligns with the project's reproducibility standards for Terraform infrastructure.
27-29: Verify the random suffix uniqueness strategy.The
random_idwithbyte_length = 4generates an 8-character hex suffix (~2³² combinations). This is suitable for typical environments but ensure it meets your organization's uniqueness requirements. Verify that the generated suffix persists across Terraform state operations and that bucket recreation scenarios are acceptable.
22-22: Validate variable references and ensure safety defaults.The bucket naming now consistently uses suffixed variables (
fixtures_bucket_name,zappa_bucket_name), and the IAM policy ARN is correctly updated. However, per the PR objectives to "add accidental deletion protection," verify:
- The variable
force_destroy_bucketdefaults tofalseto prevent unintended S3 bucket destruction.- Variable definitions (e.g.,
fixtures_bucket_name,zappa_bucket_name) are properly declared and defaults are production-safe.Also applies to: 34-34, 44-44
1-49: Confirm S3 Object Lock implementation for state bucket.The PR objectives mention enabling S3 Object Lock for the state bucket. This storage module manages fixtures and zappa deployment buckets but not the state bucket. Verify that S3 Object Lock is implemented in the backend module (
infrastructure/backend/main.tf) for the state bucket, as per the issue requirements.
d59068f to
902f4cc
Compare
|
|
||
| variable "noncurrent_version_expiration_days" { | ||
| description = "Specifies the number of days an object is noncurrent before it is expired." | ||
| description = "The number of days an object is noncurrent before it is expired." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove other "specifies" like description in other PRs and make it all consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
infrastructure/README.md (1)
206-208: Suggest minor clarification: Explain prevent_destroy reset procedure.The note correctly identifies that
prevent_destroy = truerequires manual intervention beforeterraform destroy. Consider clarifying the mechanics—e.g., editing the.tffiles to setprevent_destroy = false, or usingterraform apply -replacewith modified HCL. This helps operators understand the explicit safety mechanism.Apply this diff to clarify the cleanup process:
- Ensure all buckets and ECR repositories are empty. -**Note:** Some resources have `prevent_destroy` set to `true`. Please set it to `false` manually. +**Note:** Some resources have `prevent_destroy` set to `true`. Before running `terraform destroy`, edit the `.tf` files to set `prevent_destroy = false` on those resources, or use `-replace` with the modified configuration.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
infrastructure/README.md(4 hunks)infrastructure/backend/main.tf(4 hunks)infrastructure/modules/storage/main.tf(3 hunks)infrastructure/modules/storage/modules/s3-bucket/main.tf(1 hunks)infrastructure/modules/storage/modules/s3-bucket/variables.tf(2 hunks)infrastructure/modules/storage/variables.tf(1 hunks)infrastructure/staging/main.tf(2 hunks)infrastructure/staging/terraform.tfvars.example(0 hunks)infrastructure/staging/variables.tf(2 hunks)
💤 Files with no reviewable changes (1)
- infrastructure/staging/terraform.tfvars.example
🚧 Files skipped from review as they are similar to previous changes (4)
- infrastructure/modules/storage/variables.tf
- infrastructure/modules/storage/modules/s3-bucket/variables.tf
- infrastructure/modules/storage/main.tf
- infrastructure/modules/storage/modules/s3-bucket/main.tf
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2178
File: frontend/src/app/snapshots/[id]/page.tsx:0-0
Timestamp: 2025-09-21T17:04:48.154Z
Learning: User rudransh-shrivastava confirmed that suggested type safety improvements during Apollo Client migration were no longer relevant, reinforcing their preference to keep migration PRs focused on core migration changes rather than additional improvements.
📚 Learning: 2025-10-17T15:25:53.713Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/modules/database/main.tf:22-60
Timestamp: 2025-10-17T15:25:53.713Z
Learning: The infrastructure code in the `infrastructure/` directory is intended for quick testing purposes only, not production-grade deployment. Production-grade security hardening controls (such as IAM database authentication, deletion protection, Performance Insights KMS encryption) are not required for this testing infrastructure.
Applied to files:
infrastructure/README.md
📚 Learning: 2025-10-17T15:25:34.963Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/modules/cache/main.tf:30-30
Timestamp: 2025-10-17T15:25:34.963Z
Learning: The infrastructure/Terraform code in the OWASP Nest repository under the `infrastructure/` directory is intended for quick testing purposes only, not for production deployment.
Applied to files:
infrastructure/README.md
📚 Learning: 2025-10-23T19:22:23.811Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/main.tf:0-0
Timestamp: 2025-10-23T19:22:23.811Z
Learning: In Zappa-based serverless deployments, Lambda functions and IAM execution roles are managed by Zappa at application deployment time (via `zappa deploy`/`zappa update`), not via Terraform. Terraform provisions the supporting infrastructure (VPC, RDS, S3, security groups, RDS Proxy, Secrets Manager), while Zappa handles the Lambda orchestration layer.
Applied to files:
infrastructure/README.mdinfrastructure/staging/variables.tf
📚 Learning: 2025-11-27T19:38:23.956Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2743
File: infrastructure/modules/storage/main.tf:1-9
Timestamp: 2025-11-27T19:38:23.956Z
Learning: In the OWASP/Nest infrastructure code (infrastructure/ directory), the team prefers exact version pinning for Terraform (e.g., "1.14.0") and AWS provider (e.g., "6.22.0") over semantic versioning constraints (e.g., "~> 1.14" or "~> 6.22"). This is a deliberate choice for maximum reproducibility and explicit control over version updates in their testing environment.
Applied to files:
infrastructure/backend/main.tf
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Run frontend unit tests
- GitHub Check: Run frontend e2e tests
- GitHub Check: Run backend tests
- GitHub Check: CodeQL (javascript-typescript)
- GitHub Check: CodeQL (python)
🔇 Additional comments (10)
infrastructure/staging/variables.tf (1)
84-88: Approve: Variable renaming and default value updates.The renamed variables (
fixtures_bucket_name,zappa_bucket_name) are more descriptive, and the updated defaults include appropriate project prefixes. This aligns with the PR objectives for configurable and uniquely-named buckets.Verify that the
storagemodule inputs accept these renamed variables.Also applies to: 138-142
infrastructure/backend/main.tf (6)
8-11: Approve: Random provider addition with exact version pinning.Provider version
3.7.2is pinned exactly, which aligns with team preferences for reproducible infrastructure. The random provider is used correctly to generate unique bucket name suffixes.
53-55: Approve: Random suffix resource generates bucket name uniqueness.The
random_idresource withbyte_length = 4produces ~8 hex characters, providing sufficient entropy for bucket name uniqueness across multiple deployments. This addresses the PR objective of configurable, unique bucket names.
69-71: Approve: Lifecycle prevent_destroy rules protect critical backend resources.The
prevent_destroy = truelifecycle rule is correctly applied to the DynamoDB state lock table and both S3 buckets (logs and state). This directly addresses the PR objective of adding accidental deletion protection. Combined with the random suffix for uniqueness, these changes significantly harden the backend infrastructure.Also applies to: 78-78, 80-82, 89-94
89-90: Approve: S3 Object Lock enabled on state bucket.The
object_lock_enabled = trueparameter is set at bucket creation time (required, cannot be retrofitted), which is the correct approach. This enables the subsequent object lock configuration to take effect.
138-147: Approve: Object lock configuration with GOVERNANCE retention.The 30-day GOVERNANCE mode retention policy on the state bucket strikes a balance between protection and operational flexibility. GOVERNANCE mode allows authorized users to modify or delete objects under specified conditions, which is appropriate for a Terraform state bucket where lifecycle operations may require adjustment.
53-55: Unable to verify: State bucket naming strategy with random suffix implications.The review raises a valid concern about
random_id.suffixregeneration causing orphaned bucket names if backend state is lost or migrated. However, verification requires access to the repository to confirm whether bucket names are actually managed this way, if recovery procedures are documented, and how this pattern is used at lines 78 and 89. Reexamine this comment once repository access is available.infrastructure/README.md (2)
18-40: Approve: Backend setup documentation is clear and aligns with infrastructure changes.The one-time backend setup instructions properly guide users through creating the Terraform backend infrastructure. Notes about capturing the state bucket name and warnings against destroying backend resources align well with the hardened
prevent_destroyrules ininfrastructure/backend/main.tf.
58-75: Approve: terraform.tfbackend configuration workflow is well-documented.The new local backend configuration file approach (separate from
.tfvars) follows Terraform best practices for separating environment-specific backend settings from variable overrides. Step-by-step instructions are clear, with appropriate notes to update the state bucket name and region.infrastructure/staging/main.tf (1)
63-63: Approve: Module input variable references updated.The staging configuration correctly passes renamed variables to both
ecsandstoragemodules. Verify that the downstream module definitions ininfrastructure/modules/ecs/variables.tfandinfrastructure/modules/storage/variables.tfhave been updated to acceptfixtures_bucket_nameandzappa_bucket_nameas input variables.Also applies to: 112-112, 114-114
|



Resolves #2759
Proposed change
Make improvements to the
backendandstoragemodule:force_destroy_bucketflag completely.Checklist
make check-testlocally; all checks and tests passed.