Variables
This lesson will address Terraform variables and their uses.
We'll cover the following...
Terraform variables
A variable in Terraform is something that can be set at runtime. It allows you to vary what Terraform will do by passing in or using a dynamic value.
Our first Variable
Let’s dive into an example of how to use variables so we can learn how they work:
Press + to interact
provider "aws" {region = "us-east-2"}variable "bucket_name" {description = "the name of the bucket you wish to create"}resource "aws_s3_bucket" "bucket" {bucket = var.bucket_name}
You declare a variable by using the keyword variable
, and then specify the identifier for the variable in quotes. We are using "bucket_name"
as the identifier. Inside the variable
block, we add a ...
Access this course and 1400+ top-rated courses and projects.