-
-
Notifications
You must be signed in to change notification settings - Fork 3
Added tests #84
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
Added tests #84
Conversation
WalkthroughThe PR renames the CloudTrail label module to cloudtrail_bucket_label, updates all related ARN and context references in IAM policies, adds conditional object lock configuration based on days variables, introduces a default null value for query_override, and establishes comprehensive test infrastructure with Go tests and Atmos fixture configurations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The change involves moderate heterogeneity across Terraform configuration updates (module rename with dependent reference changes), new Go test logic with multi-method test suite implementation, and extensive configuration fixture files. While individual pieces follow clear patterns, the scope spans multiple file types and requires verification of consistency across module references and correctness of test orchestration logic. Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
|
Important Do not edit the Please update the Could you fix it @goruha? 🙏 |
|
/terratest |
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: 3
🧹 Nitpick comments (1)
test/go.mod (1)
17-17: Remove commented-out replace directive if not needed.The commented replace directive for aws-nuke appears to be unused. If it's not needed, remove it to keep the module file clean. If it's needed for documentation, consider adding a comment explaining why it's kept.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
test/go.sumis excluded by!**/*.sum
📒 Files selected for processing (16)
src/main.tf(10 hunks)src/variables.tf(1 hunks)test/.gitignore(1 hunks)test/README.md(0 hunks)test/component_test.go(1 hunks)test/fixtures/atmos.yaml(1 hunks)test/fixtures/stacks/catalog/account-map.yaml(1 hunks)test/fixtures/stacks/catalog/datadog-configuration.yaml(1 hunks)test/fixtures/stacks/catalog/datadog-integration.yaml(1 hunks)test/fixtures/stacks/catalog/usecase/basic.yaml(1 hunks)test/fixtures/stacks/catalog/usecase/disabled.yaml(1 hunks)test/fixtures/stacks/orgs/default/test/_defaults.yaml(1 hunks)test/fixtures/stacks/orgs/default/test/tests.yaml(1 hunks)test/fixtures/vendor.yaml(1 hunks)test/go.mod(1 hunks)test/run.sh(0 hunks)
💤 Files with no reviewable changes (2)
- test/run.sh
- test/README.md
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Use 2-space indentation for YAML and Markdown files
Files:
test/fixtures/stacks/catalog/datadog-configuration.yamltest/fixtures/stacks/catalog/datadog-integration.yamltest/fixtures/stacks/orgs/default/test/tests.yamltest/fixtures/vendor.yamltest/fixtures/atmos.yamltest/fixtures/stacks/orgs/default/test/_defaults.yamltest/fixtures/stacks/catalog/usecase/disabled.yamltest/fixtures/stacks/catalog/usecase/basic.yamltest/fixtures/stacks/catalog/account-map.yaml
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.tfsrc/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/variables.tfsrc/main.tf
test/**/*_test.go
📄 CodeRabbit inference engine (AGENTS.md)
test/**/*_test.go: Place tests under test/ and name them *_test.go
Use Go Terratest with github.com/cloudposse/test-helpers and Atmos fixtures for integration tests
Files:
test/component_test.go
test/component_test.go
📄 CodeRabbit inference engine (AGENTS.md)
Provide the Terratest entrypoint in test/component_test.go
Files:
test/component_test.go
test/fixtures/stacks/catalog/usecase/**
📄 CodeRabbit inference engine (AGENTS.md)
Add test scenarios under test/fixtures/stacks/catalog/usecase/
Files:
test/fixtures/stacks/catalog/usecase/disabled.yamltest/fixtures/stacks/catalog/usecase/basic.yaml
🪛 Checkov (3.2.334)
src/main.tf
[medium] 223-229: Ensure Terraform module sources use a commit hash
(CKV_TF_1)
🪛 OSV Scanner (2.2.3)
test/go.mod
[HIGH] 1-1: golang.org/x/crypto 0.33.0: Potential denial of service in golang.org/x/crypto
(GO-2025-3487)
[HIGH] 1-1: golang.org/x/crypto 0.33.0: golang.org/x/crypto Vulnerable to Denial of Service (DoS) via Slow or Incomplete Key Exchange
⏰ 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 (16)
test/.gitignore (1)
1-5: LGTM!Standard test artifact exclusions aligned with the new test infrastructure. No concerns.
test/fixtures/vendor.yaml (1)
1-35: LGTM!Well-structured Atmos vendor manifest with explicit version pinning. Component sources and target directories are properly configured.
src/variables.tf (1)
6-11: LGTM!Adding
default = nullis appropriate here given thenullable = trueconstraint and the documented fallback behavior to the default query. Explicit defaults improve clarity for module consumers.test/fixtures/atmos.yaml (1)
1-77: LGTM!Comprehensive Atmos configuration with clear documentation of ENV/CLI overrides. The 2-space indentation and glob-based path patterns align with guidelines and test infrastructure needs.
src/main.tf (3)
223-229: Module rename complete and well-applied.The rename from
cloudtrail_labeltocloudtrail_bucket_labelis applied systematically across all references (ARN construction, context passing). This improves semantic clarity about the label's purpose.Note: Static analysis flags using a version tag (
0.25.0) instead of a commit hash. Version tags (following semantic versioning) are acceptable for Cloud Posse modules and provide better flexibility than commit pinning, but consider your team's pinning strategy for consistency.
214-218: Conditional object lock configuration allows disabling via zero-day values.Setting
object_lock_configuration = nullwhendays == 0is a clean pattern for optional S3 Object Lock, avoiding drift from empty/default values. This enables test scenarios (e.g.,test/fixtures/stacks/catalog/usecase/basic.yaml) to disable Object Lock by setting bothobject_lock_days_archiveandobject_lock_days_cloudtrailto 0.Also applies to: 281-285
99-103: SourceArn condition improved for specificity.Updated SourceArn from
trail/*datadog-logs-archivewildcard totrail/${module.this.id}provides better security posture by restricting the policy to the specific CloudTrail trail, reducing blast radius if credentials are compromised.Also applies to: 133-138
test/fixtures/stacks/catalog/datadog-integration.yaml (1)
1-7: LGTM!Standard Atmos component fixture with appropriate metadata and variable configuration.
test/fixtures/stacks/catalog/usecase/disabled.yaml (1)
1-8: LGTM!Complementary fixture for testing the disabled state of the component. Naming convention (
datadog-logs-archive/disabled) clearly indicates the scenario.test/fixtures/stacks/catalog/usecase/basic.yaml (1)
1-10: LGTM!Primary test fixture for enabled component. Setting
object_lock_days_archiveandobject_lock_days_cloudtrailto 0 is intentional—this verifies the conditional null logic insrc/main.tffor disabling S3 Object Lock, providing good coverage for the feature toggle.test/fixtures/stacks/catalog/datadog-configuration.yaml (1)
1-11: LGTM!The Datadog configuration fixture is well-structured with proper 2-space indentation and appropriate test values.
test/fixtures/stacks/orgs/default/test/tests.yaml (1)
1-6: LGTM!Import structure is clean and follows the 2-space indentation guideline.
test/fixtures/stacks/catalog/account-map.yaml (1)
1-46: LGTM!The account-map fixture is well-structured with helpful comments explaining the static backend configuration. The 2-space indentation is correct.
test/fixtures/stacks/orgs/default/test/_defaults.yaml (1)
1-66: LGTM!The test defaults fixture is comprehensive and well-structured, with proper 2-space indentation and appropriate use of environment variable templates with sensible defaults.
test/component_test.go (2)
88-132: LGTM!The suite setup is well-structured, properly validates required environment variables, and correctly manages test dependencies and SSM parameters.
134-149: LGTM!Teardown and test entrypoint follow the cloudposse/test-helpers pattern correctly.
|
/terratest |
|
These changes were released in v1.537.1. |
what
Why
Summary by CodeRabbit
Release Notes
New Features
Tests
Chores