Add `atmos terraform generate planfile` command @aknysh (#1214)
## what- Add
atmos terraform generate planfile
command - Add unit tests
- Update docs
why
Use the atmos terraform generate planfile
command to generate a planfile for an Atmos Terraform/OpenTofu component in a stack in JSON or YAML formats.
Usage
Execute the terraform generate planfile
command like this:
atmos terraform generate planfile <component> -s <stack> [options]
This command generates a planfile for an Atmos terraform component in a stack.
Examples
atmos terraform generate planfile component1 -s plat-ue2-dev
atmos terraform generate planfile component1 -s plat-ue2-prod --format=json
atmos terraform generate planfile component1 -s plat-ue2-prod --format=yaml
atmos terraform generate planfile <component> -s <stack> --file=planfile.json
atmos terraform generate planfile <component> -s <stack> --format=yaml --file=planfiles/planfile.yaml
atmos terraform generate planfile <component> -s <stack> --file=/Users/me/Documents/atmos/infra/planfile.json
Validate Terraform/OpenTofu planfiles using Checkov
You can generate a planfile for a component in a stack and validate it using Checkov.
atmos terraform generate planfile <component> -s <stack>
checkov --file components/terraform/<component>/<stack>-<component>.planfile.json --framework terraform_plan
Refer to Evaluate Checkov Policies on Terraform Plan for more information.
Summary by CodeRabbit
- New Features
- Introduced a new CLI command to generate Terraform planfiles for specified components, supporting JSON and YAML output formats.
- Documentation
- Added comprehensive documentation for the new planfile generation command, including usage instructions, examples, and validation guidance.
- Updated examples and integration docs to reflect the latest CLI version and improved template usage in documentation.
- Bug Fixes
- Improved quoting in template functions and documentation examples to ensure correct string rendering in JSON outputs.
- Tests
- Added extensive tests for the new planfile generation feature, covering standard operation and error scenarios.
- Chores
- Upgraded multiple dependencies and bumped the CLI version to 1.172.0.
- Enhanced style consistency in code comments.