0
0
Terraformcloud~30 mins

Terraform apply for execution - Mini Project: Build & Apply

Choose your learning style9 modes available
Terraform apply for execution
📖 Scenario: You are working as a cloud engineer. You want to create a simple infrastructure using Terraform. You will start by defining a basic resource, then configure a variable, apply the main Terraform logic, and finally run the Terraform apply command to execute the deployment.
🎯 Goal: Build a Terraform configuration that defines an AWS S3 bucket resource, uses a variable for the bucket name, and applies the configuration to create the bucket.
📋 What You'll Learn
Create a Terraform resource for an AWS S3 bucket with a specific name
Define a variable for the bucket name
Use the variable in the resource configuration
Run the Terraform apply command to deploy the infrastructure
💡 Why This Matters
🌍 Real World
Terraform is widely used to automate cloud infrastructure deployment. Defining resources and variables is a fundamental skill for managing cloud resources efficiently.
💼 Career
Cloud engineers and DevOps professionals use Terraform to create, update, and manage infrastructure as code, enabling repeatable and consistent deployments.
Progress0 / 4 steps
1
Define the AWS S3 bucket resource
Create a Terraform resource block named aws_s3_bucket with the resource name my_bucket. Set the bucket attribute to the exact string "my-unique-bucket-12345".
Terraform
Need a hint?

Use the resource keyword followed by the resource type aws_s3_bucket and the resource name my_bucket. Inside the block, set the bucket attribute to the bucket name string.

2
Add a variable for the bucket name
Define a Terraform variable named bucket_name with the default value "my-unique-bucket-12345".
Terraform
Need a hint?

Use the variable keyword followed by the variable name bucket_name. Inside the block, set the default attribute to the bucket name string.

3
Use the variable in the S3 bucket resource
Modify the aws_s3_bucket resource named my_bucket to use the variable bucket_name for the bucket attribute instead of the fixed string.
Terraform
Need a hint?

Replace the fixed bucket name string with var.bucket_name to use the variable value.

4
Run Terraform apply to deploy the bucket
Add the Terraform command terraform apply -auto-approve as a comment to indicate running the apply step to create the S3 bucket.
Terraform
Need a hint?

Add a comment with the exact command terraform apply -auto-approve to show the deployment step.