Skip to content

Conversation

@rudransh-shrivastava
Copy link
Collaborator

@rudransh-shrivastava rudransh-shrivastava commented Dec 5, 2025

Resolves #2809

Proposed change

  • Edit pre-commit hooks.
  • Delete .terraform.lock.hcl from modules.
  • Format the README.md with consistent indentation.
  • Use stricter versioning.
  • Use secrets' ARN instead of outputs.
  • Tighten egress rules (currently all outbound traffic allowed).
  • Make variable names consistent.
  • Consistent resource tagging.
  • Consistent descriptions.
  • Add validation for variables.
  • Bug where security module updates module.security.aws_security_group.x each time terraform apply is used, despite no changes.

Checklist

  • I've read and followed the contributing guidelines.
  • I've run make check-test locally; all checks and tests passed.

@rudransh-shrivastava rudransh-shrivastava changed the base branch from main to feature/nest-zappa-migration December 5, 2025 15:09
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Summary by CodeRabbit

  • New Features

    • Added secure password storage using AWS Systems Manager Parameter Store for database and cache credentials.
  • Chores

    • Updated Terraform provider versions for improved stability and compatibility.
    • Added infrastructure linting configuration to enforce code quality standards.
    • Enhanced variable descriptions and added input validation for infrastructure parameters.
    • Refactored security group configuration for improved modularity and maintainability.
    • Updated infrastructure documentation with clearer deployment instructions and regional guidance.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Updated Terraform/provider constraints, moved DB/Redis secrets into SSM parameters and switched module interfaces to ARN form, removed module lockfiles, refactored security-group egress into explicit rules, added variable validations and TFLint/pre-commit integration, plus documentation and tagging/description standardization.

Changes

Cohort / File(s) Summary
Terraform & provider pins
infrastructure/modules/cache/main.tf, infrastructure/modules/database/main.tf, infrastructure/modules/ecs/main.tf, infrastructure/modules/ecs/modules/task/main.tf, infrastructure/modules/parameters/main.tf
Bumped terraform.required_version to 1.14.0 and pinned AWS provider to 6.22.0; updated random provider versions where present (to 3.7.2).
SSM parameters & outputs/inputs switch
infrastructure/modules/database/main.tf, infrastructure/modules/cache/main.tf, infrastructure/modules/database/outputs.tf, infrastructure/modules/cache/outputs.tf, infrastructure/modules/parameters/variables.tf, infrastructure/modules/parameters/outputs.tf, infrastructure/staging/main.tf
Added aws_ssm_parameter resources (django_db_password, django_redis_password), replaced plaintext secret variables/outputs with ARN-based variables/outputs, and wired modules to use ARN values.
Security group refactor
infrastructure/modules/security/main.tf
Removed inline egress blocks and introduced multiple aws_security_group_rule resources (ingress/egress) for ECS, Lambda, RDS, RDS Proxy, and Redis; conditional counts for proxy-related rules.
Module lockfile removals / updates
infrastructure/modules/*/.terraform.lock.hcl, infrastructure/staging/.terraform.lock.hcl
Deleted many module-level .terraform.lock.hcl files; updated infrastructure/staging/.terraform.lock.hcl provider constraints to aws = 6.22.0, random = 3.7.2.
Pre-commit & TFLint
.pre-commit-config.yaml, infrastructure/.tflint.hcl
Added TFLint configuration and passed --config=__GIT_WORKING_DIR__/infrastructure/.tflint.hcl to terraform_tflint hook; configured plugins/rules.
Tagging & common tags
infrastructure/backend/main.tf, infrastructure/modules/storage/main.tf
Added local.common_tags and merged into resource tags; added tags = var.common_tags to IAM policy resources.
Variable validations & description standardization
infrastructure/staging/variables.tf, infrastructure/modules/**/variables.tf
Added extensive validations (CIDR, ports, instance type, environment constraints) in staging variables and standardized/updated descriptions across many module variable files.
Outputs / interface updates
infrastructure/modules/cache/outputs.tf, infrastructure/modules/database/outputs.tf, infrastructure/modules/parameters/outputs.tf, infrastructure/staging/main.tf, infrastructure/modules/*/outputs.tf
Replaced sensitive plaintext outputs with SSM ARN outputs (e.g., db_password_arn, redis_password_arn), renamed outputs/variables, and standardized output descriptions.
Documentation & minor edits
infrastructure/README.md, various infrastructure/modules/*/variables.tf, infrastructure/modules/*/outputs.tf
README formatting and expanded notes; numerous description/punctuation tweaks across variables and outputs for consistency.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Areas needing extra attention:
    • infrastructure/modules/security/main.tf — validate each new aws_security_group_rule (sources, destinations, ports, types, and counts) to avoid unintended exposure or rule duplication.
    • SSM parameter wiring — verify aws_ssm_parameter configuration (type, KMS usage if required) and consistent ARN vs value usage across modules/outputs/variables.
    • infrastructure/staging/variables.tf validations — ensure regex and cidrhost validations accept intended defaults and inputs.
    • Provider/version bumps and lockfile removals — confirm CI/tooling and root lockfile strategy align with removed module-level locks.
    • TFLint/pre-commit changes — ensure hook args and new config file path work in CI and developer environments.

Possibly related issues

  • #2715 — Overlaps: module lockfile deletions, provider pinning, TFLint/pre-commit changes, security egress refactor, SSM parameter moves and variable renames.

Possibly related PRs

  • #2431 — Related: moves and patterns for SSM parameter usage and ARN wiring for secrets.
  • #2685 — Related: security-group additions/changes; overlaps in SG rule design and ECS SG adjustments.
  • #2551 — Related: earlier SSM Parameter Store integration and wiring for Django secrets.

Suggested labels

backend, ci

Suggested reviewers

  • kasya
  • arkid15r

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Make Improvements to Infrastructure Code' is vague and generic, using non-descriptive language that doesn't convey specific details about the changeset. Consider a more specific title that highlights the primary changes, such as 'Refactor infrastructure modules with stricter versioning, security group rules, and variable validation' or focus on the most impactful change.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is well-related to the changeset, listing specific improvements (pre-commit hooks, Terraform locking, versioning, security rules, tagging, validation) that align with the PR objectives and code changes.
Linked Issues check ✅ Passed The PR addresses all major coding-related requirements from issue #2809: stricter versioning [all .tf files], .terraform.lock.hcl deletion [removed from modules], pre-commit hooks [.pre-commit-config.yaml], security group rules refactor [security/main.tf], variable validation [staging/variables.tf], consistent descriptions/tagging [all modules], and secrets ARN usage [parameters module].
Out of Scope Changes check ✅ Passed All code changes are within scope of issue #2809 objectives. Documentation updates (README.md), configuration changes (TFLint, pre-commit), module refactoring, and variable/output updates directly support the stated infrastructure improvement goals.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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/security/main.tf (1)

141-150: Consider standardizing attribute ordering across security group rules.

The egress rules use consistent patterns but attribute order varies slightly. For example, some resources order attributes as count, description, from_port... while others use count, type, description, from_port.... Standardizing the order (e.g., count, description, type, from_port, to_port, protocol, cidr_blocks/source_security_group_id, security_group_id) would improve maintainability.

Also applies to: 174-182

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 358a811 and cdc1d48.

📒 Files selected for processing (12)
  • infrastructure/modules/cache/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/cache/main.tf (1 hunks)
  • infrastructure/modules/database/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/database/main.tf (1 hunks)
  • infrastructure/modules/ecs/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/ecs/main.tf (1 hunks)
  • infrastructure/modules/ecs/modules/task/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/ecs/modules/task/main.tf (1 hunks)
  • infrastructure/modules/parameters/main.tf (1 hunks)
  • infrastructure/modules/security/main.tf (6 hunks)
  • infrastructure/modules/storage/.terraform.lock.hcl (0 hunks)
  • infrastructure/staging/.terraform.lock.hcl (2 hunks)
💤 Files with no reviewable changes (5)
  • infrastructure/modules/cache/.terraform.lock.hcl
  • infrastructure/modules/ecs/.terraform.lock.hcl
  • infrastructure/modules/database/.terraform.lock.hcl
  • infrastructure/modules/ecs/modules/task/.terraform.lock.hcl
  • infrastructure/modules/storage/.terraform.lock.hcl
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
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.
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.
📚 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/ecs/main.tf
  • infrastructure/modules/database/main.tf
  • infrastructure/staging/.terraform.lock.hcl
  • infrastructure/modules/cache/main.tf
  • infrastructure/modules/ecs/modules/task/main.tf
  • infrastructure/modules/parameters/main.tf
📚 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/modules/parameters/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 frontend e2e tests
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend unit tests
  • GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (11)
infrastructure/modules/database/main.tf (1)

2-2: Version constraints properly tightened to exact pinning.

All three version constraints (Terraform, AWS provider, Random provider) have been correctly updated to exact versions, aligning with the PR objective for stricter versioning and the team's documented preference for reproducibility in the testing infrastructure. Changes are syntactically valid and consistent across modules.

Also applies to: 7-7, 11-11

infrastructure/staging/.terraform.lock.hcl (1)

6-6: Lock file constraints correctly reflect module-level version pinning.

The provider constraint strings have been properly updated to match the exact versions specified in module configurations. Presence of valid hashes confirms these versions are available in the Terraform registry. This file will be automatically regenerated by terraform init if needed.

Also applies to: 29-29

infrastructure/modules/parameters/main.tf (1)

2-2: Version constraints consistently updated for reproducibility.

Terraform and provider version constraints have been properly pinned to exact versions (1.14.0, 6.22.0, 3.7.2), maintaining consistency with other modules in the PR and supporting the PR objective of enforcing stricter versioning.

Also applies to: 7-7, 11-11

infrastructure/modules/ecs/main.tf (1)

2-2: Version constraints properly pinned for ECS module.

Terraform and AWS provider versions have been updated to exact versions (1.14.0 and 6.22.0). This module correctly declares only the AWS provider as a requirement, which is appropriate for its resource definitions.

Also applies to: 7-7

infrastructure/modules/ecs/modules/task/main.tf (1)

2-2: Version constraints correctly pinned for ECS task submodule.

Terraform and AWS provider versions have been appropriately updated to exact versions. This submodule correctly depends only on the AWS provider, which aligns with its resource scope (CloudWatch and ECS task definitions).

Also applies to: 7-7

infrastructure/modules/cache/main.tf (1)

2-2: Cache module version constraints properly tightened.

All three Terraform and provider version constraints have been updated to exact versions (1.14.0, 6.22.0, 3.7.2). The module appropriately declares both AWS and Random providers, which are both required for ElastiCache configuration and auth token generation.

Also applies to: 7-7, 11-11

infrastructure/modules/security/main.tf (5)

1-10: Version pinning looks solid.

Exact version constraints align with your team's preference for reproducibility and explicit control.

Based on learnings, this approach matches the team's deliberate choice for maximum reproducibility in the testing environment.


108-172: Conditional RDS logic is well-structured.

The mutual exclusivity between direct RDS connections (lines 108–128) and RDS Proxy connections (lines 130–172) is correctly implemented using count conditions. This approach should also resolve the terraform drift issue mentioned in the PR by providing explicit resource lifecycle management instead of inline blocks.


184-202: Verify that var.redis_port variable is defined in variables.tf.

The Redis ingress rules (lines 184–202) reference var.redis_port. Confirm this variable is defined with an appropriate default value (typically 6379 for Redis).


58-106: Verify that variable var.default_egress_cidr_blocks is defined in variables.tf.

The egress rules on lines 58–66, 78–86, and 98–106 reference var.default_egress_cidr_blocks, which must be defined upstream. Confirm that the variable exists and contains the intended CIDR blocks (e.g., ["0.0.0.0/0"] for full internet egress).


68-76: Verify that variable var.vpc_endpoint_sg_id is defined.

The VPC endpoint rules reference var.vpc_endpoint_sg_id on lines 73 and 93, which should point to the VPC endpoint security group. Confirm this variable is defined in variables.tf.

Also applies to: 88-96

@github-actions github-actions bot added the docs Improvements or additions to documentation label Dec 6, 2025
@rudransh-shrivastava rudransh-shrivastava force-pushed the feature/nest-zappa-migration-improvements branch from 7ab99cf to e66427b Compare December 6, 2025 14:41
@github-actions github-actions bot added docs Improvements or additions to documentation and removed docs Improvements or additions to documentation labels Dec 6, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
infrastructure/modules/database/variables.tf (1)

1-116: Consider establishing a consistent description pattern across all variables.

While the changes to the boolean variable descriptions are good, the file still shows mixed description styles across different variable types (some starting with "The", others with "A", "Whether", or "List of"). As part of the broader "Consistent descriptions" objective, consider establishing a style guide for variable descriptions (e.g., boolean variables always use "Whether...", and apply it consistently across this module and others.

infrastructure/modules/ecs/variables.tf (2)

1-4: Complete the variable description consistency pass across the file.

The aws_region description now ends with a period, which improves consistency. However, many other descriptions in this file lack periods (e.g., ecs_sg_id, environment, fixtures_read_only_policy_arn, etc.). Since "Consistent descriptions" is a stated PR objective, consider completing this formatting pass for all variable descriptions in one go.

Example fix to apply consistently across the file:

 variable "ecs_sg_id" {
-  description = "The ID of the security group for the ECS tasks"
+  description = "The ID of the security group for the ECS tasks."
   type        = string
 }

 variable "environment" {
-  description = "The environment (e.g., staging, production)"
+  description = "The environment (e.g., staging, production)."
   type        = string
 }

Based on the PR objectives, this aligns with the goal to ensure consistent resource descriptions across the infrastructure code.


85-88: Note: Variable validation blocks are pending per PR objectives.

The PR objectives mark "Add validation for variables" as pending. Consider adding validation blocks where appropriate (e.g., validating that project_name and environment follow naming conventions, or that task CPU/memory values meet expected ranges), when that work is prioritized.

Example (if needed):

variable "project_name" {
  description = "The name of the project."
  type        = string
  validation {
    condition     = length(var.project_name) > 0
    error_message = "Project name must not be empty."
  }
}
infrastructure/README.md (1)

20-24: Markdown linting violations: nested list indentation (MD007).

The nested bullet points under numbered sections use 2-space indentation, which improves visual hierarchy but violates markdownlint's MD007 rule (expects 0 indentation). While this formatting choice enhances readability, it conflicts with strict GitHub-flavored Markdown compliance.

Decide whether to:

  • Accept the style trade-off for improved readability, and update the linting configuration to allow/disable MD007, or
  • Reformat all nested lists to start at column 0 and rely on numbered sub-items (e.g., "1.1", "1.2") or dashes at root level for hierarchy.

Also applies to: 29-33, 35-39, 49-53, 55-59, 61-65, 67-71, 73-77, 85-89, 91-95, 99-100

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e66427b and 540c3c0.

📒 Files selected for processing (8)
  • infrastructure/README.md (2 hunks)
  • infrastructure/backend/variables.tf (1 hunks)
  • infrastructure/modules/cache/variables.tf (1 hunks)
  • infrastructure/modules/database/variables.tf (2 hunks)
  • infrastructure/modules/ecs/variables.tf (2 hunks)
  • infrastructure/modules/networking/modules/nacl/variables.tf (1 hunks)
  • infrastructure/modules/networking/modules/vpc-endpoint/variables.tf (1 hunks)
  • infrastructure/modules/security/variables.tf (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • infrastructure/modules/networking/modules/vpc-endpoint/variables.tf
  • infrastructure/backend/variables.tf
  • infrastructure/modules/security/variables.tf
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
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.
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.
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/providers.tf:1-3
Timestamp: 2025-10-17T15:25:55.624Z
Learning: The infrastructure code in the OWASP/Nest repository (infrastructure/ directory) is intended for quick testing purposes only, not for production deployment.
📚 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-17T15:25:55.624Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/providers.tf:1-3
Timestamp: 2025-10-17T15:25:55.624Z
Learning: The infrastructure code in the OWASP/Nest repository (infrastructure/ directory) is intended for quick testing purposes only, not for production deployment.

Applied to files:

  • infrastructure/README.md
📚 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/README.md
🪛 LanguageTool
infrastructure/README.md

[style] ~234-~234: Using many exclamation marks might seem excessive (in this case: 13 exclamation marks for a text that’s 4635 characters long)
Context: ...ets and ECR repositories are empty. > [!NOTE] > Some resources have `prevent_des...

(EN_EXCESSIVE_EXCLAMATION)

🪛 markdownlint-cli2 (0.18.1)
infrastructure/README.md

20-20: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


29-29: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


35-35: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


43-43: Blank line inside blockquote

(MD028, no-blanks-blockquote)


49-49: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


55-55: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


61-61: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


67-67: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


73-73: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


81-81: Blank line inside blockquote

(MD028, no-blanks-blockquote)


85-85: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


91-91: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


99-99: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


100-100: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


108-108: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


119-119: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


120-120: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


121-121: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


129-129: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


135-135: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


143-143: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


165-165: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


169-169: Blank line inside blockquote

(MD028, no-blanks-blockquote)


177-177: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


183-183: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


192-192: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


203-203: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


211-211: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


212-212: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


213-213: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


214-214: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


215-215: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


216-216: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


217-217: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


218-218: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


219-219: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


220-220: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


221-221: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


222-222: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)

⏰ 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)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests
🔇 Additional comments (5)
infrastructure/modules/networking/modules/nacl/variables.tf (1)

2-2: Excellent consistency improvements to variable descriptions.

All variable descriptions have been updated to follow a consistent, more descriptive format. Particularly nice touches:

  • Complete phrasing with article + noun structure ("A map of...", "The CIDR block for...")
  • Helpful example for the environment variable showing expected values
  • Clear, unambiguous language across all descriptions

These changes improve developer experience and documentation quality with zero behavioral impact.

Also applies to: 7-7, 12-12, 17-17, 22-22, 27-27, 32-32

infrastructure/modules/database/variables.tf (1)

31-31: Approve description simplifications for boolean variables.

The descriptions for db_copy_tags_to_snapshot (line 31) and db_skip_final_snapshot (line 71) have been simplified by removing verbose prefixes ("Specifies whether", "Determines whether") and using "Whether" directly. This improves readability and aligns with the PR objective of ensuring consistent descriptions.

Also applies to: 71-71

infrastructure/modules/cache/variables.tf (1)

2-2: Description improvement aligns with documentation goals.

The simplified description is more concise and clearer. This change moves the documentation toward consistency as outlined in the PR objectives.

infrastructure/README.md (2)

234-235: Disregard linting warning about excessive exclamation marks.

LanguageTool's EN_EXCESSIVE_EXCLAMATION flag is a false positive caused by the [!NOTE] and [!WARNING] GFM alert syntax. These exclamation marks are part of standard GitHub-flavored Markdown alert formatting, not excessive punctuation in prose.


1-255: Documentation structure and clarity are strong.

The README provides clear, step-by-step setup instructions with helpful note blocks and explicit examples. The expanded format (e.g., breaking commands into sub-steps and adding context) improves accessibility for users unfamiliar with infrastructure provisioning.

@rudransh-shrivastava rudransh-shrivastava force-pushed the feature/nest-zappa-migration-improvements branch from 28c89b2 to d6e72a7 Compare December 7, 2025 13:40
@rudransh-shrivastava rudransh-shrivastava changed the title [WIP] Make Improvements to Infrastructure Code Make Improvements to Infrastructure Code Dec 7, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 7, 2025

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (2)
infrastructure/modules/ecs/variables.tf (1)

1-124: Consider adding input validation blocks for required variables.

The PR objectives mention adding validation for variables, but this file only updates descriptions with trailing periods. Consider adding validation blocks for variables like ecs_sg_id, fixtures_bucket_name, and task resource specifications to catch invalid inputs early. For example:

variable "ecs_sg_id" {
  description = "The ID of the security group for the ECS tasks."
  type        = string
  
  validation {
    condition     = can(regex("^sg-[0-9a-f]{8}$|^sg-[0-9a-f]{17}$", var.ecs_sg_id))
    error_message = "Must be a valid security group ID."
  }
}
infrastructure/modules/cache/variables.tf (1)

1-75: Consider adding input validation for Redis configuration variables.

Similar to the ECS module, variable descriptions have been standardized with trailing periods, but the PR objectives mention adding variable validation. Consider adding validation for critical variables like redis_port, redis_num_cache_nodes, and redis_engine_version to ensure valid inputs. For example:

variable "redis_port" {
  description = "The port for the Redis cache."
  type        = number
  
  validation {
    condition     = var.redis_port >= 1024 && var.redis_port <= 65535
    error_message = "Redis port must be between 1024 and 65535."
  }
}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28c89b2 and d6e72a7.

📒 Files selected for processing (40)
  • .pre-commit-config.yaml (1 hunks)
  • infrastructure/.tflint.hcl (1 hunks)
  • infrastructure/README.md (2 hunks)
  • infrastructure/backend/main.tf (4 hunks)
  • infrastructure/backend/variables.tf (1 hunks)
  • infrastructure/modules/cache/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/cache/main.tf (2 hunks)
  • infrastructure/modules/cache/outputs.tf (1 hunks)
  • infrastructure/modules/cache/variables.tf (4 hunks)
  • infrastructure/modules/database/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/database/main.tf (3 hunks)
  • infrastructure/modules/database/outputs.tf (1 hunks)
  • infrastructure/modules/database/variables.tf (5 hunks)
  • infrastructure/modules/ecs/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/ecs/main.tf (4 hunks)
  • infrastructure/modules/ecs/modules/task/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/ecs/modules/task/main.tf (1 hunks)
  • infrastructure/modules/ecs/outputs.tf (1 hunks)
  • infrastructure/modules/ecs/variables.tf (2 hunks)
  • infrastructure/modules/networking/modules/nacl/variables.tf (1 hunks)
  • infrastructure/modules/networking/modules/vpc-endpoint/outputs.tf (1 hunks)
  • infrastructure/modules/networking/modules/vpc-endpoint/variables.tf (1 hunks)
  • infrastructure/modules/networking/outputs.tf (1 hunks)
  • infrastructure/modules/networking/variables.tf (3 hunks)
  • infrastructure/modules/parameters/main.tf (1 hunks)
  • infrastructure/modules/parameters/outputs.tf (1 hunks)
  • infrastructure/modules/parameters/variables.tf (2 hunks)
  • infrastructure/modules/security/main.tf (4 hunks)
  • infrastructure/modules/security/outputs.tf (1 hunks)
  • infrastructure/modules/security/variables.tf (2 hunks)
  • infrastructure/modules/storage/.terraform.lock.hcl (0 hunks)
  • infrastructure/modules/storage/main.tf (1 hunks)
  • infrastructure/modules/storage/modules/s3-bucket/outputs.tf (1 hunks)
  • infrastructure/modules/storage/modules/s3-bucket/variables.tf (1 hunks)
  • infrastructure/modules/storage/outputs.tf (1 hunks)
  • infrastructure/modules/storage/variables.tf (1 hunks)
  • infrastructure/staging/.terraform.lock.hcl (2 hunks)
  • infrastructure/staging/main.tf (2 hunks)
  • infrastructure/staging/outputs.tf (1 hunks)
  • infrastructure/staging/variables.tf (4 hunks)
💤 Files with no reviewable changes (5)
  • infrastructure/modules/storage/.terraform.lock.hcl
  • infrastructure/modules/cache/.terraform.lock.hcl
  • infrastructure/modules/ecs/modules/task/.terraform.lock.hcl
  • infrastructure/modules/database/.terraform.lock.hcl
  • infrastructure/modules/ecs/.terraform.lock.hcl
✅ Files skipped from review due to trivial changes (2)
  • infrastructure/modules/storage/outputs.tf
  • infrastructure/modules/storage/modules/s3-bucket/variables.tf
🚧 Files skipped from review as they are similar to previous changes (14)
  • infrastructure/modules/ecs/modules/task/main.tf
  • infrastructure/modules/networking/variables.tf
  • infrastructure/modules/database/outputs.tf
  • infrastructure/modules/networking/outputs.tf
  • infrastructure/modules/parameters/variables.tf
  • infrastructure/modules/networking/modules/nacl/variables.tf
  • infrastructure/modules/ecs/outputs.tf
  • infrastructure/.tflint.hcl
  • infrastructure/modules/networking/modules/vpc-endpoint/outputs.tf
  • infrastructure/staging/.terraform.lock.hcl
  • infrastructure/modules/storage/modules/s3-bucket/outputs.tf
  • infrastructure/staging/main.tf
  • infrastructure/modules/security/variables.tf
  • infrastructure/staging/variables.tf
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
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.
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.
📚 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/modules/cache/variables.tf
  • infrastructure/modules/parameters/main.tf
  • infrastructure/modules/cache/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/parameters/main.tf
  • infrastructure/modules/ecs/main.tf
  • infrastructure/modules/database/main.tf
  • infrastructure/modules/cache/main.tf
📚 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/modules/parameters/outputs.tf
  • infrastructure/README.md
  • infrastructure/modules/cache/main.tf
📚 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-09-21T17:04:48.154Z
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.

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-17T15:25:55.624Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2431
File: infrastructure/providers.tf:1-3
Timestamp: 2025-10-17T15:25:55.624Z
Learning: The infrastructure code in the OWASP/Nest repository (infrastructure/ directory) is intended for quick testing purposes only, not for production deployment.

Applied to files:

  • infrastructure/README.md
🪛 Checkov (3.2.334)
infrastructure/modules/database/main.tf

[high] 80-86: Ensure SSM parameters are using KMS CMK

(CKV_AWS_337)

infrastructure/modules/cache/main.tf

[high] 86-92: Ensure SSM parameters are using KMS CMK

(CKV_AWS_337)

🪛 LanguageTool
infrastructure/README.md

[style] ~234-~234: Using many exclamation marks might seem excessive (in this case: 13 exclamation marks for a text that’s 4635 characters long)
Context: ...ets and ECR repositories are empty. > [!NOTE] > Some resources have `prevent_des...

(EN_EXCESSIVE_EXCLAMATION)

🪛 markdownlint-cli2 (0.18.1)
infrastructure/README.md

20-20: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


29-29: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


35-35: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


43-43: Blank line inside blockquote

(MD028, no-blanks-blockquote)


49-49: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


55-55: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


61-61: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


67-67: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


73-73: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


81-81: Blank line inside blockquote

(MD028, no-blanks-blockquote)


85-85: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


91-91: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


99-99: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


100-100: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


108-108: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


119-119: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


120-120: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


121-121: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


129-129: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


135-135: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


143-143: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


165-165: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


169-169: Blank line inside blockquote

(MD028, no-blanks-blockquote)


177-177: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


183-183: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


192-192: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


203-203: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


211-211: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


212-212: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


213-213: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


214-214: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


215-215: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


216-216: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


217-217: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


218-218: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


219-219: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


220-220: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


221-221: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


222-222: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)

⏰ 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)
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend unit tests
🔇 Additional comments (29)
infrastructure/modules/storage/variables.tf (1)

8-8: ✓ Consistent description formatting applied across all variables.

All variable descriptions have been updated to end with periods, improving consistency and alignment with documentation standards. These formatting changes are minor but beneficial for maintainability.

Also applies to: 13-13, 18-18, 23-23

.pre-commit-config.yaml (1)

19-20: Verify that the .tflint.hcl file exists and is properly formatted.

The __GIT_WORKING_DIR__ placeholder and --args=--config= syntax are valid and officially supported by pre-commit-terraform (documented in their README with examples matching this exact pattern). However, confirm that infrastructure/.tflint.hcl exists and contains valid HCL configuration before merging.

Likely an incorrect or invalid review comment.

infrastructure/backend/main.tf (2)

15-21: Well-structured tagging pattern with centralized locals.

The introduction of locals.common_tags provides a consistent, reusable tagging foundation across backend resources. The use of merge() to combine common tags with resource-specific Name tags is a clean, extensible pattern that aligns with the PR's tagging standardization objective.


2-2: Version pinning approach aligns with project standards.

Exact version pinning (e.g., "1.14.0" instead of "~> 1.14") ensures reproducibility in this testing environment. Based on learnings, this deliberate choice is consistent with OWASP/Nest infrastructure practices.

Also applies to: 6-6, 10-10

infrastructure/backend/variables.tf (1)

2-2: Description improved for clarity.

The revised description is more concise and direct, removing unnecessary phrasing. This aligns with the PR's objective to standardize variable descriptions across modules.

infrastructure/README.md (1)

1-255: Documentation formatting improvements enhance readability.

The README has been updated with improved indentation, clearer step sequencing, and better organization of code blocks and notes. These changes align with the PR's broader consistency and clarity improvements. The formatting changes use GitHub's standard alert syntax (> [!NOTE], > [!WARNING]), which is correct and renders properly on GitHub.

infrastructure/modules/cache/main.tf (2)

2-2: Version pinning follows project standard.

Exact version constraints align with OWASP/Nest infrastructure practices for reproducibility.

Also applies to: 7-7, 11-11


86-92: Verify KMS CMK requirement for SSM parameters in testing environment.

The new aws_ssm_parameter resource uses type = "SecureString", which encrypts the value with AWS's managed key by default. However, Checkov flagged this with CKV_AWS_337, which requires a customer-managed KMS key.

Given that this infrastructure is for testing purposes (per learnings), clarify whether the additional overhead of managing a customer-managed KMS key is necessary. If the testing environment does not require this level of encryption, you may suppress this check via a Checkov comment or update project guidelines.

infrastructure/modules/networking/modules/vpc-endpoint/variables.tf (1)

2-2: Variable descriptions improved for consistency and clarity.

The updated descriptions are more explicit, include proper articles, and maintain consistent grammar. Examples help clarify variable content (e.g., "The environment (e.g., staging, production)."). These changes align with the PR's descriptive consistency objective across the infrastructure codebase.

Also applies to: 7-7, 12-12, 17-17, 22-22, 27-27, 32-32, 37-37, 42-42

infrastructure/modules/storage/main.tf (1)

53-53: Consistent tagging applied to IAM policy.

Adding tags = var.common_tags to the aws_iam_policy resource extends the PR's tagging standardization objective to IAM resources, improving resource discoverability and cost allocation across the infrastructure.

infrastructure/modules/ecs/main.tf (2)

2-2: Version pinning aligns with project standards.

Exact version constraints ensure reproducible builds in the testing environment.

Also applies to: 7-7


83-83: Consistent tagging applied across IAM policies.

All three IAM policies (ecs_tasks_execution_role_ssm_policy, ecs_tasks_execution_policy, event_bridge_ecs_policy) now include tags = var.common_tags, aligning with the PR's tagging standardization objective. This enables better resource tracking and cost allocation across the ECS infrastructure.

Also applies to: 119-119, 200-200

infrastructure/modules/cache/outputs.tf (2)

7-7: Minor description improvement for consistency.

Adding a period to the redis_primary_endpoint description maintains consistency with the descriptive standardization throughout the PR.


1-4: Secrets exposed via ARN instead of direct output.

The new redis_password_arn output follows the PR's objective to use secrets' ARN instead of exposing raw values, improving security by allowing downstream consumers to fetch the actual secret from AWS Systems Manager Parameter Store.

Verify that all downstream consumers (e.g., parameters module, ECS task definitions) have been updated to reference redis_password_arn instead of the previously removed redis_auth_token output.

infrastructure/modules/parameters/main.tf (2)

1-14: Exact version pinning follows team conventions and ensures reproducibility.

The provider versions are correctly pinned to exact versions (Terraform 1.14.0, AWS 6.22.0, Random 3.7.2), which aligns with the team's preference for maximum reproducibility in the testing environment. This is the right approach for this codebase.


16-175: SSM parameter configuration and tagging are consistent.

All SSM parameters properly apply tags = var.common_tags and use lifecycle.ignore_changes = [value] to allow manual updates via AWS console without Terraform conflicts. This approach is consistent with the established pattern in the parameters module and supports the staged deployment workflow.

infrastructure/modules/parameters/outputs.tf (1)

1-22: ARN-based credential references decouple password management from parameter distribution.

The output has been renamed to django_ssm_parameter_arns and now references var.db_password_arn and var.redis_password_arn instead of managing passwords directly. This approach decentralizes password generation and management to the database and cache modules, while this module acts as a parameter aggregator. Verify that the database and cache modules correctly export these ARN outputs and that the staging module properly wires them as inputs.

infrastructure/modules/database/main.tf (3)

1-14: Exact version pinning provides reproducibility consistency.

Provider versions are correctly exact-pinned across Terraform and AWS provider, aligning with team conventions. This ensures consistent behavior across deployments in the testing environment.


16-35: Password generation with fallback to input variable is sound, with appropriate character restrictions.

The locals block (lines 16–19) implements a sensible pattern: generate a random password only if none is provided, otherwise use the input. The random_password resource explicitly avoids problematic special characters that could cause issues with database connection strings or shell escaping. This is a pragmatic approach for handling secrets in infrastructure code.


80-86: KMS CMK encryption for SSM parameters is planned as a follow-up enhancement.

The aws_ssm_parameter resource currently uses AWS-managed keys. While Checkov flags this (CKV_AWS_337) as a security best practice, KMS CMK encryption for sensitive SSM parameters in this module is planned to be implemented after S3 state management is completed. For the current testing infrastructure, AWS-managed keys are acceptable as an interim measure.

Ensure this work is tracked in the project roadmap and prioritize implementation once S3 state management is in place.

infrastructure/staging/outputs.tf (1)

1-19: Output descriptions are now consistently punctuated.

The descriptions have been standardized with trailing periods, improving consistency across the infrastructure codebase. No functional changes to output values.

infrastructure/modules/security/outputs.tf (1)

1-24: Output descriptions are now consistently formatted.

Descriptions have been updated with trailing periods for consistency across the security module outputs. No functional changes to the security group ID references.

infrastructure/modules/security/main.tf (4)

12-56: Security groups now defined without inline rules to prevent Terraform drift.

The security groups are now defined with empty inline rule blocks, allowing external aws_security_group_rule resources to manage all ingress and egress rules independently. This approach directly addresses the PR objective to "fix bug where security module updates aws_security_group.x each apply despite no changes." By separating rule management, Terraform will no longer detect unintended drift when rules are managed externally.


58-96: Review egress rule scope and alignment with "tighten egress" PR objective.

The new ecs_egress_all and lambda_egress_all rules (lines 58–66, 78–86) allow all outbound traffic (protocol = "-1", ports 0–65535) to CIDR blocks defined in var.default_egress_cidr_blocks. The PR objectives state "Tighten egress rules (currently all outbound traffic allowed)," but these rules still permit unrestricted outbound traffic.

Verify that:

  1. var.default_egress_cidr_blocks is configured restrictively in the staging environment (e.g., not ["0.0.0.0/0"])
  2. These rules are intentionally broad for testing purposes, or if they should be tightened further

If the intent is to restrict egress to specific destinations (e.g., only to RDS, Redis, and VPC endpoints), consider removing these catch-all rules and explicitly list allowed destinations instead.


98-162: RDS and RDS Proxy rules use count-based conditionals correctly.

Rules for RDS and RDS Proxy ingress/egress properly use count to depend on var.create_rds_proxy:

  • When create_rds_proxy = false: RDS accepts direct connections from ECS and Lambda (lines 98–118)
  • When create_rds_proxy = true: RDS accepts only from RDS Proxy, and RDS Proxy accepts from ECS/Lambda with egress to RDS

This conditional approach ensures correct rule configuration based on the deployment topology.


164-182: Lambda-to-Redis ingress rule is a new addition; verify the requirement.

A new security group rule (lines 174–182) explicitly allows Lambda to connect to Redis on the Redis port. This is a functional addition not visible in prior versions. Confirm:

  1. Lambda functions in this deployment actually need direct Redis access
  2. If this was previously missing and caused issues, document the fix in the commit message
infrastructure/modules/database/variables.tf (3)

7-122: Description consistency improvements align with PR objectives.

All variable descriptions have been updated to follow a consistent format with trailing periods and clear, standardized wording. This improves documentation clarity and maintainability across the module.


70-74: Verify password handling with default = null.

The db_password variable now has sensitive = true and default = null, which aligns with the PR objective to "Use secrets' ARN instead of outputs." Confirm that:

  1. The module's main.tf correctly handles the null default and retrieves the actual password from AWS Secrets Manager using an ARN.
  2. The RDS resource creation doesn't fail if no password is explicitly provided (i.e., the password generation or retrieval from Secrets Manager is mandatory in the implementation).

1-122: Verify variable validation blocks.

The PR summary states "Add validation for variables — done," but the provided file does not contain validation blocks. Confirm whether:

  1. Variable validation constraints were added to this file but are not shown in the provided context.
  2. Validation was implemented in main.tf via resource-level constraints instead.
  3. Validation is enforced elsewhere (e.g., in a .tfvars file or external tooling like TFLint).

Run rg -n 'validation' infrastructure/modules/database/ to search for validation blocks across all files in the database module.

@rudransh-shrivastava rudransh-shrivastava marked this pull request as ready for review December 7, 2025 13:57
@arkid15r arkid15r merged commit 1ec00d3 into OWASP:feature/nest-zappa-migration Dec 8, 2025
26 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 8, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Improvements to Infrastructure Code

2 participants