-
-
Notifications
You must be signed in to change notification settings - Fork 3
Fix cloudtrail s3 bucket name #82
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
Conversation
WalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Root as Root Module
participant This as module.this
participant Label as module.cloudtrail_label
participant Bucket as module.cloudtrail_s3_bucket
participant IAM as aws_iam_policy_document
participant DD as datadog_logs_archive
participant Loc as locals
Note over Root,Label: New label module created
Root->>Label: create label (name="datadog-logs-archive-cloudtrail", context=module.this.context)
Note over Root,Bucket: Bucket/context wiring changed
Root->>Bucket: create bucket (context=module.cloudtrail_label.context)
Note over IAM,Label: IAM ARNs now reference label id
IAM->>Label: read id -> build ARN arn:...:s3:::${module.cloudtrail_label.id}/*
Note over Loc,DD: Query selection (default vs override)
Loc->>Loc: compute default_query using stage/account/additional_query_tags
Loc->>DD: provide local.query (var.query_override ? override : default_query)
DD->>Root: create datadog_logs_archive (query=local.query)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (2)src/{main,variables,outputs,providers,versions,context}.tf📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.tf📄 CodeRabbit inference engine (AGENTS.md)
Files:
🪛 Checkov (3.2.334)src/main.tf[medium] 223-229: Ensure Terraform module sources use a commit hash (CKV_TF_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)
🔇 Additional comments (5)
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 (1)
src/main.tf (1)
219-225: Consider pinning module source by commit hash for enhanced reproducibility.The module uses semantic versioning; Checkov recommends explicit commit hashing for version control determinism. This ensures the exact module code is used across deployments, mitigating risks from minor version changes.
Apply this diff to pin by commit hash (verify the current commit hash for v0.25.0 from the registry):
module "cloudtrail_label" { - source = "cloudposse/label/null" - version = "0.25.0" # requires Terraform >= 0.13.0 + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=0.25.0"Alternatively, you can look up the commit hash for tag
0.25.0from the module's repository if you prefer explicit commit pinning.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main.tf(5 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/{main,variables,outputs,providers,versions,context}.tf
📄 CodeRabbit inference engine (AGENTS.md)
Keep the Terraform component’s source of truth in src/ with canonical files: main.tf, variables.tf, outputs.tf, providers.tf, versions.tf, and context.tf
Files:
src/main.tf
**/*.tf
📄 CodeRabbit inference engine (AGENTS.md)
**/*.tf: Use 2-space indentation for all Terraform files
In Terraform, use lower_snake_case for variables and locals; keep resource/data source names descriptive and aligned with Cloud Posse null-label patterns
Run terraform fmt and adhere to TFLint rules defined in .tflint.hcl; do not commit formatting or lint violations
Files:
src/main.tf
🪛 Checkov (3.2.334)
src/main.tf
[medium] 219-225: Ensure Terraform module sources use a commit hash
(CKV_TF_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). (1)
- GitHub Check: Summary
🔇 Additional comments (2)
src/main.tf (2)
64-64: IAM policy ARN updates establish correct bucket reference.The ARN updates correctly reference
module.cloudtrail_label.idinstead of manual composition. This ensures the policy grants permissions to the exact bucket provisioned by thecloudtrail_s3_bucketmodule, establishing a single authoritative source for the bucket name.Also applies to: 83-83, 118-118
293-293: Context change correctly establishes input-driven naming with no issues.Verification confirms the shift to
module.cloudtrail_label.contextsuccessfully resolves the circular dependency. The s3-bucket v4.10.0 module derives its bucket name from the context using Cloud Posse's null-label logic (same as cloudtrail_label), producing a bucket ID matchingmodule.cloudtrail_label.idalready referenced in the policy ARNs (lines 64, 83, 118). Naming is now upstream-dependent on the label module rather than downstream-dependent on bucket outputs.
Added a new variable 'query_override' for customizable query in Datadog archive.
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/variables.tf(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/{main,variables,outputs,providers,versions,context}.tf
📄 CodeRabbit inference engine (AGENTS.md)
Keep the Terraform component’s source of truth in src/ with canonical files: main.tf, variables.tf, outputs.tf, providers.tf, versions.tf, and context.tf
Files:
src/variables.tf
**/*.tf
📄 CodeRabbit inference engine (AGENTS.md)
**/*.tf: Use 2-space indentation for all Terraform files
In Terraform, use lower_snake_case for variables and locals; keep resource/data source names descriptive and aligned with Cloud Posse null-label patterns
Run terraform fmt and adhere to TFLint rules defined in .tflint.hcl; do not commit formatting or lint violations
Files:
src/variables.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). (1)
- GitHub Check: Summary
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Changed query_override variable type to string and made it nullable.
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main.tf(7 hunks)src/variables.tf(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/variables.tf
🧰 Additional context used
📓 Path-based instructions (2)
src/{main,variables,outputs,providers,versions,context}.tf
📄 CodeRabbit inference engine (AGENTS.md)
Keep the Terraform component’s source of truth in src/ with canonical files: main.tf, variables.tf, outputs.tf, providers.tf, versions.tf, and context.tf
Files:
src/main.tf
**/*.tf
📄 CodeRabbit inference engine (AGENTS.md)
**/*.tf: Use 2-space indentation for all Terraform files
In Terraform, use lower_snake_case for variables and locals; keep resource/data source names descriptive and aligned with Cloud Posse null-label patterns
Run terraform fmt and adhere to TFLint rules defined in .tflint.hcl; do not commit formatting or lint violations
Files:
src/main.tf
🪛 Checkov (3.2.334)
src/main.tf
[medium] 224-230: Ensure Terraform module sources use a commit hash
(CKV_TF_1)
🪛 GitHub Actions: Branch
src/main.tf
[error] 1-1: Command 'git diff --exit-code' failed with exit code 1. CI pipeline halted due to uncommitted changes or non-zero diff check.
⏰ 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: Summary
🔇 Additional comments (3)
src/main.tf (3)
224-230: Context propagation verified and dependency loop resolved.All assertions have been confirmed:
- ✓ Lines 69, 88, 123 correctly use
module.cloudtrail_label.idin ARNs- ✓ Line 298 correctly uses
module.cloudtrail_label.contextfor S3 bucket context- ✓ Module receives context from
module.this.context(line 228)- ✓ No remaining references to
module.this.idormodule.this.contextin cloudtrail-related ARNsThe implementation correctly isolates cloudtrail bucket naming through the dedicated label module, breaking the circular dependency mentioned in issue #71.
30-33: All verification points confirmed—locals logic and query override implementation are correct.✓ The
concat()in line 31 produces the expected Datadog query format:"env:{stage} OR account:{aws_account_id} OR {additional_query_tags}"✓ The
query_overridevariable in variables.tf is typedoptional(string), correctly matching the null check in line 33✓ The
logs_archiveresource (line 346) correctly referenceslocal.query; thecatchall_archiveresource intentionally uses hardcoded"*"(by design). All inline query construction has been migrated to locals.
224-230: Review comment is incorrect and should be disregarded.The module
cloudposse/label/nullis a Terraform Registry module and is already correctly pinned to semantic version0.25.0. Registry modules require semantic version tags; Terraform Registry publishes releases by semantic-version tags (vMAJOR.MINOR.PATCH), and non-semver tags are ignored.Commit hashes apply only to git/mercurial sources (pinned via
?ref=), not registry modules. The codebase already follows the correct pattern: registry modules use version constraints while git sources use?ref=with commit references (e.g.,?ref=v1.536.0insrc/providers.tf). The.tflint.hclenforces this withterraform_module_version(enabled), and the README.md explicitly advises "pinning each module to the exact version you're using."CKV_TF_1 is intended for unversioned git/mercurial sources, not registry modules. The code is compliant with organizational standards.
Likely an incorrect or invalid review comment.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
These changes were released in v1.537.0. |
what
query_overridevariablewhy
references
Summary by CodeRabbit
New Features
Chores