Free courses
InfrastructureBeginnerFree
Build a Cloud Web Server with Terraform
Write Terraform configuration to define a cloud web server, apply it safely by reviewing a plan first, and destroy the resources when you are done.
6 lessons 31 minNo account needed
Start lesson 1What you will learn
- Write Terraform configuration that describes a cloud web server.
- Run terraform init, plan, and apply to create and update resources.
- Read a plan to see what Terraform will change before applying it.
- Use input variables to make a configuration reusable.
- Destroy all resources with terraform destroy to stop further cost.
Before you start
- Run commands in a terminal.
- Edit plain text files.
- Understand what a virtual machine is in cloud computing.
Lessons
- Lesson 1: Set up Terraform and choose a providerInstall Terraform, create a project folder, write a provider block, and run terraform init to download the provider.6 min
- Lesson 2: Allow web traffic with a security groupAdd a security group resource that opens port 80 from the internet so the server can be reached.4 min
- Lesson 3: Create the virtual machineAdd an instance resource that uses the security group and runs a simple web server on first boot.4 min
- Lesson 4: Print the server addressAdd an output value that prints the instance public IP address so you can open the web page.6 min
- Lesson 5: Use variables for reusable settingsReplace hard-coded values such as region and instance type with variables and a variable definitions file.5 min
- Lesson 6: Apply, verify, and destroy the serverRun terraform apply to create everything, visit the web page to confirm it works, then run terraform destroy to remove all resources.6 min