Variables :
We are going to call these variables because you want to hold variables are they are a way of setting a value that we can use multiple times.
String:
variable "vpcname" {
type = string
default = "myvpc"
}
How to Use Strings
resource "aws_vpc" "myname" {
number:
variable "sshport" {
type = number
default = 22
}
Note: number or integers don't go in double quote.
Boolen
variable "enabled" {
default = true
}
#list
It can be store one type of data(string or boolean).
so this example I am going to use string. Arrays or list, there's an order.Its allow start with zero.
variable "mylist" {
type = list()
default = ["value1", "value2"]
}
example:
How to Use Strings
resource "aws_vpc" "myname" {
cidr_block = "10.0.0.1/16"
tag {
Name = mylist[]
}
}
#Input
Input variables serve as parameters for a Terraform module.
Input variables are like function arguments.
Output values are like function return values.
Local values are like a function's temporary local variables.
variable "image_id" {
type = string
description = "The id of the machine image (AMI) to use for the server."
}
#map
Map is key value pair.
variable "mymap" {
type = map
default = {
key1 = "value1"
key2 = "value2"
}
No comments:
Post a Comment