0
0
Terraformcloud~30 mins

Resource documentation reference in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Terraform Resource Documentation Reference
📖 Scenario: You are working on a Terraform project to manage cloud infrastructure. To write correct Terraform code, you need to refer to the official resource documentation for the cloud provider.In this project, you will practice how to create a Terraform configuration that references resource documentation correctly by defining a simple resource with exact attributes.
🎯 Goal: Create a Terraform configuration that defines an AWS S3 bucket resource using exact attribute names and values as specified in the official AWS S3 bucket resource documentation.
📋 What You'll Learn
Create a Terraform configuration file named main.tf.
Define an AWS S3 bucket resource with the exact name my_bucket.
Set the bucket name to my-unique-bucket-12345.
Enable versioning on the bucket using the correct nested block as per documentation.
Use the official Terraform AWS provider resource attribute names exactly.
💡 Why This Matters
🌍 Real World
Terraform is widely used to manage cloud infrastructure. Knowing how to read and apply resource documentation ensures you write correct and effective infrastructure code.
💼 Career
Cloud engineers and DevOps professionals must reference official Terraform documentation to configure resources properly and avoid errors in infrastructure deployments.
Progress0 / 4 steps
1
Create the Terraform provider block
Create a Terraform provider block for AWS with the region set to us-east-1. Use the exact block name provider "aws" and set region = "us-east-1" inside it.
Terraform
Need a hint?

Refer to the Terraform AWS provider documentation for the syntax of the provider block.

2
Define the AWS S3 bucket resource
Add a resource block for an AWS S3 bucket with the exact resource type aws_s3_bucket and the resource name my_bucket. Set the bucket name attribute bucket to "my-unique-bucket-12345".
Terraform
Need a hint?

Check the AWS S3 bucket resource documentation for the exact attribute name to set the bucket name.

3
Enable versioning on the S3 bucket
Inside the aws_s3_bucket resource block named my_bucket, add a nested block named versioning. Inside it, set the attribute enabled to true to enable versioning on the bucket.
Terraform
Need a hint?

Refer to the AWS S3 bucket resource documentation for how to enable versioning using the versioning nested block.

4
Add a tag to the S3 bucket
Inside the aws_s3_bucket resource block named my_bucket, add a tags attribute. Set it to a map with a single key-value pair: Environment = "Dev".
Terraform
Need a hint?

Check the resource documentation for the correct syntax to add tags as a map attribute.