Terraform for DevOps part-6

Terraform for DevOps part-6

On the 39th day, I learned the following things about Terraform.

Terraform .tfstate file and destroy Command

  • After the creating the terraform.tf file and creating a repository on GitHub, two more files will created after that. Those files are terraform.tfstate and terraform.tfstate.backup.
  • Open the terraform.tfstate file and it will show you all the resources that you have created in terraform.tf file.
  • If you want to create another repository, you can add it in the terraform.tf file.
  • After adding the second repository code in the file, type terraform plan command. It will show the new repository resources to be added.
  • Write terraform apply --auto-approve command. Auto approve won't ask you YES or NO option everytime and it will make the second repository without making changes in the first one.
  • Open the terraform.tfstate file and it will show you the first repository resources and the second repository resources that you have created.
  • Open the terraform.tfstate.backup and it will show you the backup of the earlier resources that you have created.
  • Tip: Don't try to manually change the .tfstate file.

Terraform Destroy

  • If you want to destroy the resources, you can do it by writing, terraform destroy. It will destroy all the resources and the repositories that you have created.

If you want to destroy a specific resource, you can do this by simply writing terraform destroy --target github_repository.terraform-second-repo.

  • If you write terraform plan, it will show you the resources of the second repository that needs to be added.

Terraform Validate Command

  • Before showing you how to validate the terraform, let's make some changes in the terraform files.
  • Open the terraform.tf file, copy the provider and paste into the provider.tf file.
  • Remove the token from the provider.tf file and write the following data into it.

provider "github" { token = "${var.token}" }        

  • Make a variable.tf file and write the following data into it.variable token {}
  • Make a terraform.tfvars file and write the token inside it.

token="<token>"        

  • After making these changes, type terraform validate command and it will give you the message Success! The configuration is valid.
  • Now you can destroy and apply the configuration file.


That's all about my today learning I hope you like this article

please share with your frineds and network

happy learning : )

要查看或添加评论,请登录

Sahil Bhoyar的更多文章

  • Helm for DevOps part-2

    Helm for DevOps part-2

    On the 59th day, I learned the following things about Helm. Helm Commands will interact with charts or YAML files…

    1 条评论
  • Helm for DevOps

    Helm for DevOps

    On the 58th day, I learned the following things about Helm. Helm Before discussing helm, let's understand the common…

    2 条评论
  • EC2 Instance part-4

    EC2 Instance part-4

    On the 57th day, I learned the following things about Cloud Computing. AWS Demo Go to AWS and create an account.

  • EC2 instance part-3

    EC2 instance part-3

    On the 56th day, I learned the following things about Cloud Computing. 5.

    2 条评论
  • AWS EC2 Instance part-2

    AWS EC2 Instance part-2

    On the 55th day, I learned the following things about Cloud Computing. 3.

  • EC2 Instance

    EC2 Instance

    On the 54th day, I learned the following things about Cloud Computing. Elastic Compute Cloud Amazon EC2 or virtual…

    1 条评论
  • Cloud for DevOps

    Cloud for DevOps

    On the 53rd day, I learned the following things about Cloud Computing. Cloud Computing Cloud computing is an on-demand…

    1 条评论
  • Nagios installation

    Nagios installation

    On the 52th day, I learned the following things about Continuous Monitoring. Installation of Nagios Step 1 To start…

  • Nagios for DevOps

    Nagios for DevOps

    On the 51th day, I learned the following things about Continuous Monitoring. Continuous Monitoring Tool Monitoring is…

  • Jenkins for DevOps part-4

    Jenkins for DevOps part-4

    On the 50th day, I learned the following things about CI/CD Pipeline. Build after another project is build (jenkins…

    1 条评论

社区洞察

其他会员也浏览了