0
0
Terraformcloud~30 mins

Block syntax and structure in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Terraform Block Syntax and Structure
📖 Scenario: You are setting up a simple cloud infrastructure using Terraform. You will create a configuration file that defines a provider and a resource using proper block syntax and structure.
🎯 Goal: Build a valid Terraform configuration with a provider block for AWS and a resource block to create an AWS S3 bucket.
📋 What You'll Learn
Use correct Terraform block syntax with curly braces
Define a provider block named aws with region us-east-1
Define a resource block of type aws_s3_bucket named my_bucket
Set the bucket attribute inside the resource block to my-unique-bucket-12345
💡 Why This Matters
🌍 Real World
Terraform is widely used to define and manage cloud infrastructure as code, making deployments repeatable and consistent.
💼 Career
Understanding Terraform block syntax is essential for cloud engineers and DevOps professionals to write and maintain infrastructure code.
Progress0 / 4 steps
1
Create the provider block
Write a Terraform provider block named aws with the attribute region set to "us-east-1". Use proper block syntax with curly braces.
Terraform
Need a hint?

Remember to open and close the block with curly braces and indent the attribute inside.

2
Add the resource block skeleton
Add a Terraform resource block of type aws_s3_bucket named my_bucket. Use proper block syntax with curly braces.
Terraform
Need a hint?

Use the keyword resource followed by the resource type and name in quotes, then open and close curly braces.

3
Set the bucket attribute inside the resource block
Inside the resource "aws_s3_bucket" "my_bucket" block, add the attribute bucket and set it to "my-unique-bucket-12345". Use proper indentation.
Terraform
Need a hint?

Indent the attribute inside the resource block and use an equals sign to assign the value.

4
Complete the Terraform configuration
Ensure the Terraform configuration has the provider "aws" block with region "us-east-1" and the resource "aws_s3_bucket" "my_bucket" block with the bucket attribute set to "my-unique-bucket-12345". The blocks must be properly closed with curly braces.
Terraform
Need a hint?

Check that all blocks are properly opened and closed with curly braces and attributes are correctly set.