Skip to content

Commit

Permalink
Merge atmos specific and terraform help documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
samtholiya committed Dec 14, 2024
1 parent c0e7054 commit f0b7b98
Showing 1 changed file with 51 additions and 36 deletions.
87 changes: 51 additions & 36 deletions internal/exec/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/cloudposse/atmos/pkg/schema"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/cloudposse/atmos/pkg/version"
)

// processHelp processes help commands
Expand All @@ -21,41 +20,57 @@ func processHelp(
u.PrintMessage(fmt.Sprintf("atmos %s <command> <component> --stack <stack> [options]", componentType))

if componentType == "terraform" {
u.PrintMessage("\nAdditions and differences from native terraform:")
u.PrintMessage(" - before executing other 'terraform' commands, 'atmos' runs 'terraform init'")
u.PrintMessage(" - you can skip over atmos calling 'terraform init' if you know your project is already in a good working state by using " +
"the '--skip-init' flag like so 'atmos terraform <command> <component> -s <stack> --skip-init")
u.PrintMessage(" - 'atmos terraform deploy' command executes 'terraform apply -auto-approve' (sets the '-auto-approve' flag when running 'terraform apply')")
u.PrintMessage(" - 'atmos terraform deploy' command supports '--deploy-run-init=true/false' flag to enable/disable running 'terraform init' " +
"before executing the command")
u.PrintMessage(" - 'atmos terraform apply' and 'atmos terraform deploy' commands support '--from-plan' flag. If the flag is specified, " +
"the commands will use the planfile previously generated by 'atmos terraform plan' command instead of generating a new planfile")
u.PrintMessage(" - 'atmos terraform apply' and 'atmos terraform deploy' commands commands support '--planfile' flag to specify the path " +
"to a planfile. The '--planfile' flag should be used instead of the planfile argument in the native 'terraform apply <planfile>' command")
u.PrintMessage(" - 'atmos terraform clean' command deletes the '.terraform' folder, '.terraform.lock.hcl' lock file, " +
"and the previously generated 'planfile', 'varfile', and 'backend.tf.json' file for the specified component and stack. " +
"Use the --everything flag to also delete the Terraform state files and directories for the component. " +
"Note: State files store the local state of your infrastructure and should be handled with care, if not using a remote backend.\n\n" +
"Additional flags:\n" +
" --force Forcefully delete Terraform state files and directories without interaction\n" +
" --skip-lock-file Skip deleting the '.terraform.lock.hcl' file\n\n" +
"If no component or stack is specified, the clean operation will apply globally to all components.")
u.PrintMessage(" - 'atmos terraform workspace' command first runs 'terraform init -reconfigure', then 'terraform workspace select', " +
"and if the workspace was not created before, it then runs 'terraform workspace new'")
u.PrintMessage(" - 'atmos terraform import' command searches for 'region' in the variables for the specified component and stack, " +
"and if it finds it, sets 'AWS_REGION=<region>' ENV var before executing the command")
u.PrintMessage(" - 'atmos terraform generate backend' command generates a backend config file for an 'atmos' component in a stack")
u.PrintMessage(" - 'atmos terraform generate backends' command generates backend config files for all 'atmos' components in all stacks")
u.PrintMessage(" - 'atmos terraform generate varfile' command generates a varfile for an 'atmos' component in a stack")
u.PrintMessage(" - 'atmos terraform generate varfiles' command generates varfiles for all 'atmos' components in all stacks")
u.PrintMessage(" - 'atmos terraform shell' command configures an environment for an 'atmos' component in a stack and starts a new shell " +
"allowing executing all native terraform commands inside the shell without using atmos-specific arguments and flags")
u.PrintMessage(" - double-dash '--' can be used to signify the end of the options for Atmos and the start of the additional " +
"native arguments and flags for the 'terraform' commands. " +
"For example: atmos terraform plan <component> -s <stack> -- -refresh=false -lock=false")
u.PrintMessage(fmt.Sprintf(" - '--append-user-agent' flag sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. "+
"Example: 'Atmos/%s (Cloud Posse; +https://atmos.tools)'. "+
"If not specified, defaults to 'atmos %s'\n", version.Version, version.Version))
u.PrintMessage(`
Usage: atmos terraform [global options] <subcommand> [args]
The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.
Atmos commands:
generate backend Command generates a backend config file for an 'atmos' component in a stack
generate backends Command generates backend config files for all 'atmos' components in all stacks
generate varfile Command generates a varfile for an 'atmos' component in a stack
generate varfiles Command generates varfiles for all 'atmos' components in all stacks
shell Command configures an environment for an 'atmos' component in a stack and starts a new shell allowing executing all native terraform commands inside the shell without using atmos-specific arguments and flags
double-dash '--' Can be used to signify the end of the options for Atmos and the start of the additional native arguments and flags for the 'terraform' commands. For example: atmos terraform plan <component> -s <stack> -- -refresh=false -lock=false
'--append-user-agent' Flag sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. Example: 'Atmos/0.0.1 (Cloud Posse; +https://atmos.tools)'. If not specified, defaults to 'atmos 0.0.1'
Main commands:
init Prepare your working directory for other commands
validate Check whether the configuration is valid
plan Show changes required by the current configuration
apply Create or update infrastructure
destroy Destroy previously-created infrastructure
All other commands:
console Try Terraform expressions at an interactive command prompt
fmt Reformat your configuration in the standard style
force-unlock Release a stuck lock on the current workspace
get Install or upgrade remote Terraform modules
graph Generate a Graphviz graph of the steps in an operation
import Associate existing infrastructure with a Terraform resource
login Obtain and save credentials for a remote host
logout Remove locally-stored credentials for a remote host
metadata Metadata related commands
modules Show all declared modules in a working directory
output Show output values from your root module
providers Show the providers required for this configuration
refresh Update the state to match remote systems
show Show the current state or a saved plan
state Advanced state management
taint Mark a resource instance as not fully functional
test Execute integration tests for Terraform modules
untaint Remove the 'tainted' state from a resource instance
version Show the current Terraform version
workspace Workspace management
Global options (use these before the subcommand, if any):
-chdir=DIR Switch to a different working directory before executing the
given subcommand.
-help Show this help output, or the help for a specified subcommand.
-version An alias for the "version" subcommand.
`)
}

if componentType == "helmfile" {
Expand Down

0 comments on commit f0b7b98

Please sign in to comment.