🚀 Enhancements
Add `terraform shell` command. Improve/update `atmos help` @aknysh (#103)
what
- Add
terraform shell
command - Improve/update
atmos help
why
-
Simplifies component provisioning by using more familiar Terraform command syntax without atmos-specific arguments and flags
-
After executing
atmos terraform shell <component> -s <stack>
command, the CLI generates all the required variables for the component in the stack, create a Terraform workspace, and drops the user into a separate shell (process) with all the required paths and ENV vars set, allowing execution of all native Terraform commands using the native syntax
test
> atmos terraform shell test/test-component-override-3 -s=tenant1-ue2-dev
Variables for the component 'test/test-component-override-3' in the stack 'tenant1/ue2/dev':
enabled: true
environment: ue2
namespace: eg
region: us-east-2
service_1_list:
- 5
- 6
- 7
service_1_map:
a: 1
b: 6
c: 7
d: 8
service_1_name: mixin-2
service_2_list:
- 4
- 5
- 6
service_2_map:
a: 4
b: 5
c: 6
service_2_name: service-2-override-2
stage: dev
tenant: tenant1
Writing the variables to file:
examples/complete/components/terraform/test/test-component/tenant1-ue2-dev-test-test-component-override-3.terraform.tfvars.json
Executing command:
/usr/local/bin/terraform init
Initializing modules...
Initializing the backend...
Initializing provider plugins...
Terraform has been successfully initialized!
Command info:
Terraform binary: terraform
Terraform command: shell
Arguments and flags: []
Component: test/test-component-override-3
Terraform component: test/test-component
Inheritance: test/test-component-override-3 -> mixin/test-2 -> mixin/test-1 -> test/test-component-override-2 -> test/test-component-override -> test/test-component
Stack: tenant1/ue2/dev
Working dir: examples/complete/components/terraform/test/test-component
Executing command:
/usr/local/bin/terraform workspace select tenant1-ue2-dev-test-component-override-3
Workspace "tenant1-ue2-dev-test-component-override-3" doesn't exist.
You can create this workspace with the "new" subcommand.
Executing command:
/usr/local/bin/terraform workspace new tenant1-ue2-dev-test-component-override-3
Created and switched to workspace "tenant1-ue2-dev-test-component-override-3"!
You're now on a new, empty workspace. Workspaces isolate their state,
so if you run "terraform plan" Terraform will not see any existing state
for this configuration.
Starting a new interactive shell where you can execute all native Terraform commands (type 'exit' to go back)
Component: test/test-component-override-3
Stack: tenant1/ue2/dev
Working directory: examples/complete/components/terraform/test/test-component
Terraform workspace: tenant1-ue2-dev-test-component-override-3
Setting the ENV vars in the shell:
TEST_ENV_VAR1=val1-override-3
TEST_ENV_VAR2=val2-override-3
TEST_ENV_VAR3=val3-override-3
TEST_ENV_VAR4=val4-override-3
TF_CLI_ARGS_plan=-var-file=tenant1-ue2-dev-test-test-component-override-3.terraform.tfvars.json
TF_CLI_ARGS_apply=-var-file=tenant1-ue2-dev-test-test-component-override-3.terraform.tfvars.json
TF_CLI_ARGS_refresh=-var-file=tenant1-ue2-dev-test-test-component-override-3.terraform.tfvars.json
TF_CLI_ARGS_import=-var-file=tenant1-ue2-dev-test-test-component-override-3.terraform.tfvars.json
TF_CLI_ARGS_destroy=-var-file=tenant1-ue2-dev-test-test-component-override-3.terraform.tfvars.json
test-component > terraform apply
Changes to Outputs:
+ service_1_id = "eg-ue2-dev-mixin-2"
+ service_2_id = "eg-ue2-dev-service-2-override-2"
You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
Do you want to perform these actions in workspace "tenant1-ue2-dev-test-component-override-3"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
service_1_id = "eg-ue2-dev-mixin-2"
service_2_id = "eg-ue2-dev-service-2-override-2"
> test-component > terraform output
service_1_id = "eg-ue2-dev-mixin-2"
service_2_id = "eg-ue2-dev-service-2-override-2"
test-component > exit
Exited shell: exit status 0
>