Day 1 of 5
⏱ ~60 minutes
Terraform in 5 Days — Day 1

HCL Basics and Your First Resource

Install Terraform, understand HCL syntax, configure a provider, and provision your first cloud resource.

What Terraform Does

You describe the infrastructure you want in HCL files. Terraform talks to cloud APIs to create, update, or delete resources to match your description. The same config works across AWS, GCP, Azure, and 800+ other providers.

Install
# Download from terraform.io/downloads
# Mac: brew install hashicorp/tap/terraform
terraform --version
main.tf — AWS example
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

# Create an S3 bucket
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-unique-bucket-name-12345"

  tags = {
    Environment = "dev"
    Project     = "terraform-course"
  }
}
Core workflow
terraform init     # download providers
terraform plan     # preview changes
terraform apply    # apply changes (prompts for confirmation)
terraform destroy  # tear everything down
💡
Run terraform plan before every apply. It shows exactly what will be created, modified, or destroyed — like a dry run. Review it carefully. Surprises in plan are much better than surprises in production.
📝 Day 1 Exercise
Provision Your First Resource
  1. I
  2. n
  3. s
  4. t
  5. a
  6. l
  7. l
  8. T
  9. e
  10. r
  11. r
  12. a
  13. f
  14. o
  15. r
  16. m
  17. .
  18. C
  19. o
  20. n
  21. f
  22. i
  23. g
  24. u
  25. r
  26. e
  27. t
  28. h
  29. e
  30. A
  31. W
  32. S
  33. p
  34. r
  35. o
  36. v
  37. i
  38. d
  39. e
  40. r
  41. (
  42. o
  43. r
  44. G
  45. C
  46. P
  47. i
  48. f
  49. y
  50. o
  51. u
  52. p
  53. r
  54. e
  55. f
  56. e
  57. r
  58. )
  59. .
  60. W
  61. r
  62. i
  63. t
  64. e
  65. a
  66. m
  67. a
  68. i
  69. n
  70. .
  71. t
  72. f
  73. t
  74. h
  75. a
  76. t
  77. c
  78. r
  79. e
  80. a
  81. t
  82. e
  83. s
  84. a
  85. n
  86. S
  87. 3
  88. b
  89. u
  90. c
  91. k
  92. e
  93. t
  94. (
  95. o
  96. r
  97. G
  98. C
  99. S
  100. b
  101. u
  102. c
  103. k
  104. e
  105. t
  106. )
  107. .
  108. R
  109. u
  110. n
  111. i
  112. n
  113. i
  114. t
  115. ,
  116. p
  117. l
  118. a
  119. n
  120. ,
  121. a
  122. p
  123. p
  124. l
  125. y
  126. .
  127. V
  128. e
  129. r
  130. i
  131. f
  132. y
  133. t
  134. h
  135. e
  136. b
  137. u
  138. c
  139. k
  140. e
  141. t
  142. e
  143. x
  144. i
  145. s
  146. t
  147. s
  148. i
  149. n
  150. t
  151. h
  152. e
  153. c
  154. o
  155. n
  156. s
  157. o
  158. l
  159. e
  160. .
  161. R
  162. u
  163. n
  164. d
  165. e
  166. s
  167. t
  168. r
  169. o
  170. y
  171. .

Day 1 Summary

  • HCL is declarative: describe what you want, not how to get it.
  • terraform init downloads providers. plan previews. apply executes. destroy tears down.
  • Provider block configures the cloud. Resource block defines what to create.
  • Always review terraform plan output before applying.
Finished this lesson?