Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

terraform

Which command can be used to create infrastructure in Terraform?

Umme Ammara

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Once you have successfully initialized a Terraform project, you can create the infrastructure using two alternatives:

  • Run the terraform plan command first, which creates an execution plan for the infrastructure. This command alone will not modify/create the infrastructure. To apply the changes, run the terraform apply command upon confirming the proposed changes.

  • Run the terraform apply command directly. This command automatically runs the terraform plan command, which creates an execution plan for the infrastructure. Upon confirmation of the proposed changes, the terraform apply command starts building the infrastructure.

The following illustration shows the steps mentioned above:

Terraform plan

The terraform plan command creates the execution plan by doing the following:

  • Accessing the currently existing state to make sure that Terraform is up to date.

  • Making a note of the differences between the proposed configuration and the previous state.

  • Propose a set of changes required to attain the infrastructure desired by the developer.

Once the execution plan is complete, the terraform plan will not start making the changes. Once the user has confirmed the changes, the terraform apply command is needed.

Terraform apply

Once you run the terraform apply command in the terminal, various options will appear, such as planning options, planning modes, and other options. The apply command pauses until the user gives their confirmation. Once done, the application will start, and the proposed plan will begin executing. After the terraform apply command finishes, Terraform will display a message indicating the successful application to the user.

To read more about the options in terraform apply and terraform plan, click here.

RELATED TAGS

terraform

CONTRIBUTOR

Umme Ammara
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring