Sunday, January 26, 2020

Terraform frequent commands

$ cat /tmp/tfhelp | awk '{$1=$1;print}' | awk -F ' ' '{$1=""; print $0}' | sort -u
 cat terraform
 cat /usr/local/bin/terraform
 cd .terraform/modules/cell_shared.databricks_email_notification/
 cd .terraform/modules/cell_shared.databricks_email_notification/modules
 history | grep terraform > /tmp/tfhelp
 rm -rf .terraform && terraform init
 rm -rf .terraform && terraform init && terraform plan -out tf.plan
 rm -rf .terraform && terraform init && terraform plan -out tf.plan | tee -a out.plan
 rm -rf .terraform && terraform init && terraform plan -out tf.plan | tee /tmp/wfplan
 rm -rf .terraform && terraform init && terraform plan -out tf.plan | tee /tmp/wfplan2
 terraform apply
 terraform apply "tf.plan"
 terraform apply tf.plan
 terraform apply "tf.plan" terraform apply "tf.plan" terraform apply "tf.plan"terraform apply "tf.plan"
 terraform destroy
 terraform destroy --target=module.nomad.module.nomad_cluster.aws_autoscaling_group.nomad[0]
 terraform destroy --target=module.ops_tgw.aws_ram_resource_share.ops_tgw
 terraform init
 terraform init && terraform plan -out tf.plan
 terraform output
 terraform outputs
 terraform plan
 terraform plan -out tf.plan
 terraform plan -out tf.plan && terraform apply tf.plan
 terraform resources
 terraform state list
 terraform state list |grep boot
 terraform state list |grep vault
 terraform state list |grep vault |grep boot
 terraform state outputs
 terraform taint module.vault_bootstrap.null_resource.vault_bootstrap
 TF_DEBUG=true && terraform plan -out tf.plan
 TF_LOG=DEBUG && terraform apply tf.plan
 TF_LOG=DEBUG && terraform plan -out tf.plan
 vim terraform
 vim .terraform/modules/cell_shared.databricks_email_notification/main.tf
 vim .terraform/modules/cell_shared.databricks_email_notification/modules/
 vim .terraform/modules/cell_shared.databricks_email_notification/modules/api_gateway/main.tf
 vim .terraform/modules/cell_shared.databricks_email_notification/modules/lambda_function/main.tf
 vim .terraform/modules/cell_shared.zookeeper/modules/zookeeper_nomad_job/main.tf
 vim .terraform/modules/cell_shared.zookeeper/modules/zookeeper_nomad_job/zookeeper_server_nomad.tpl
 vim /usr/local/bin/terraform
 vi .terraform/modules/cell_eap/kube_application_roles.tf
 vi .terraform/modules/cross_connectivity_for_crypter_usw2_vpc/modules/cross_connectivity/main.tf
 vi .terraform/modules/vault_config/auth/aws/main.tf
 vi .terraform/modules/vault_config/auth/aws/variables.tf
 which terraform

3 comments:

  1. This brings back memories of my early days managing infrastructure. I used to rely heavily on terraform output to pass values around. Looking at your list, I realize I haven’t tried combining logs with plan output the way you’ve shown. Do you think newer users should start with just the basics or dive into advanced flags early when learning Terraform?

    ReplyDelete
    Replies
    1. https://github.com/MiqdadProjects/kodekloud-terraform-solutions
      https://github.com/kodekloudhub/terraform-for-beginners-course
      These repositories should be good enough to get started for beginners.

      Delete
  2. Learn some basics and test them out immediately
    Practicing consistently helps improve.

    1. Hashicorp website for the basics
    https://developer.hashicorp.com/terraform/tutorials
    2. kodecloud for free Terraform labs
    3. Book: Terraform Up and Running to make your code Production ready
    4. Do the “Cloud resume Challenge - AWS “ and keep responding to questions from newbies
    https://cloudresumechallenge.dev/
    5. Always use AI to ask questions & improve yourself
    At the end of the day, you should be able to visualize and form a mental picture of how stuff works.

    ReplyDelete

Terraform Again