Add atmos terraform generate planfile command#1214
Conversation
website/docs/cli/commands/terraform/terraform-generate-planfile.mdx
Outdated
Show resolved
Hide resolved
…e.mdx Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>
tests/fixtures/scenarios/terraform-generate-planfile/components/terraform/mock/main.tf
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/exec/terraform_generate_planfile.go (1)
212-212: Use the defined error format constant for consistencyThe error wrapping format string is used directly here, while other locations use the ErrWrappingFormat constant.
- return fmt.Errorf("%w: %w", ErrConvertingJsonToGoType, err) + return fmt.Errorf(ErrWrappingFormat, ErrConvertingJsonToGoType, err)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
internal/exec/terraform_generate_planfile.go(1 hunks)internal/exec/terraform_generate_planfile_test.go(1 hunks)tests/fixtures/scenarios/terraform-generate-planfile/atmos.yaml(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/fixtures/scenarios/terraform-generate-planfile/atmos.yaml
- internal/exec/terraform_generate_planfile_test.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (6)
internal/exec/terraform_generate_planfile.go (6)
17-24: Errors are appropriately definedGood job defining comprehensive error variables to clarify different types of errors that might occur during execution. This improves error handling and makes debugging easier.
26-35: Well-designed options structureThe PlanfileOptions struct provides a clean way to group related parameters, solving the "too many arguments" issue identified in previous reviews. This pattern improves maintainability and readability.
37-93: Command execution function looks solidThe function thoroughly validates inputs, properly extracts flags, and safely passes pointers to the execution function. The early check for empty arguments at line 39 prevents panic conditions.
95-165: Core execution function is well-structuredThe function has been nicely refactored into smaller, focused helper functions that follow the single responsibility principle. The temporary directory is properly managed with deferred cleanup.
125-136: Good resource managementProperly creating and cleaning up the temporary directory with a deferred function call. The warning log on cleanup failure is a thoughtful addition.
167-223: Helper functions are well-designedBreaking the functionality into smaller, focused helper functions improves readability and testability. Each function has a clear purpose and appropriate error handling.
|
Hello! I am currently testing this new functionality and finding that it's hanging. Not quite sure how to debug or troubleshoot further. Suggestions? |
|
@cfsb-jrose can you re-run the command with |
what
atmos terraform generate planfilecommandwhy
Use the
atmos terraform generate planfilecommand to generate a planfile for an Atmos Terraform/OpenTofu component in a stack in JSON or YAML formats.atmos terraform generate planshould create JSON file #1172Usage
Execute the
terraform generate planfilecommand like this:This command generates a planfile for an Atmos terraform component in a stack.
Examples
Validate Terraform/OpenTofu planfiles using Checkov
You can generate a planfile for a component in a stack and validate it using Checkov.
Refer to Evaluate Checkov Policies on Terraform Plan for more information.
Summary by CodeRabbit