Variable Defaults
This lesson will teach you how to set defaults in Terraform variables and their use.
We'll cover the following...
We'll cover the following...
Project example
Consider the following project:
Press + to interact
provider "aws" {region = "us-east-2"}variable "bucket_name" {description = "the name of the bucket you wish to create"}variable "bucket_suffix" {default = "-abcd"}resource "aws_s3_bucket" "bucket" {bucket = "${var.bucket_name}${var.bucket_suffix}"}
We have extended the first example and added a second variable "bucket_suffix"
which has its default set to "-abcd"
. Setting a default on a variable
means that if you do not provide a value for that variable, then the default will be used. We then use the ...