Skip to content

Commit

Permalink
variable validation add
Browse files Browse the repository at this point in the history
  • Loading branch information
Great-Stone committed Nov 6, 2023
1 parent 37ad354 commit 2fa4cca
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
55 changes: 55 additions & 0 deletions exercises/variables.tf.validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
##############################################################################
# Variables File
#
# Here is where we store the default values for all the variables used in our
# Terraform code. If you create a variable with no default, the user will be
# prompted to enter it (or define it via config file or command line flags.)

variable "prefix" {
description = "This prefix will be included in the name of most resources."
}

variable "region" {
description = "The region where the resources are created."
default = "us-east-1"

validation {
condition = contains(["us-east-1", "us-west-1", "eu-west-2", "p-southeast-1"], var.region)
error_message = "region 변수는 us-east-1, us-west-1, eu-west-2, p-southeast-1 중 하나여야 합니다."
}
}

variable "address_space" {
description = "The address space that is used by the virtual network. You can supply more than one address space. Changing this forces a new resource to be created."
default = "10.0.0.0/16"
}

variable "subnet_prefix" {
description = "The address prefix to use for the subnet."
default = "10.0.10.0/24"
}

variable "instance_type" {
description = "Specifies the AWS instance type."
default = "t2.micro"
}

variable "admin_username" {
description = "Administrator user name for mysql"
default = "hashicorp"
}

variable "height" {
default = "400"
description = "Image height in pixels."
}

variable "width" {
default = "600"
description = "Image width in pixels."
}

variable "placeholder" {
default = "placekitten.com"
description = "Image-as-a-service URL. Some other fun ones to try are fillmurray.com, placecage.com, placebeard.it, loremflickr.com, baconmockup.com, placeimg.com, placebear.com, placeskull.com, stevensegallery.com, placedog.net"
}
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ variable "prefix" {

variable "region" {
description = "The region where the resources are created."
default = "ap-northeast-1"
default = "us-east-1"
}

variable "address_space" {
Expand Down

0 comments on commit 2fa4cca

Please sign in to comment.