-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvariables.tf
166 lines (148 loc) · 4.38 KB
/
variables.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Variable Definition Precendence (the last ones take the precendence)
# https://developer.hashicorp.com/terraform/language/values/variables#variable-definition-precedence
#-----------------
## Environment variables
## The terraform.tfvars file, if present.
## The terraform.tfvars.json file, if present.
## Any *.auto.tfvars or *.auto.tfvars.json files, processed in lexical order of their filenames.
## Any -var and -var-file options on the command line, in the order they are provided. (This includes variables set by a Terraform Cloud workspace.)
#------------------------------------------------
## aws configuration
#------------------------------------------------
variable "profile" {
description = "Put your AWS CLI profile name. Type \"default\" if you have no especific profile. The value will not be shown since it is set as sensitive."
type = string
sensitive = true
}
variable "target_region" {
type = string
default = "ap-southeast-2"
sensitive = true
}
#------------------------------------------------
## vpc (a nat gateway will also be deployed in the first_public_subnet)
#------------------------------------------------
variable "vpc_cidr_block" {
type = string
default = "10.0.0.0/16"
}
variable "public_subnet_config" {
type = list(object({
cidr_block = string
az_name = string
}))
default = [
{
cidr_block = "10.0.1.0/24"
az_name = "ap-southeast-2a"
},
{
cidr_block = "10.0.2.0/24"
az_name = "ap-southeast-2b"
},
{
cidr_block = "10.0.3.0/24"
az_name = "ap-southeast-2c"
},
]
}
variable "private_subnet_config" {
type = list(object({
cidr_block = string
az_name = string
}))
default = [
{
cidr_block = "10.0.101.0/24"
az_name = "ap-southeast-2a"
},
{
cidr_block = "10.0.102.0/24"
az_name = "ap-southeast-2b"
},
{
cidr_block = "10.0.103.0/24"
az_name = "ap-southeast-2c"
},
]
}
#------------------------------------------------
## tags and naming conventions
#------------------------------------------------
#use in a resource --> tags = var.common_tags
variable "common_tags" {
description = "Common tags to set for resources (will be set for locals' common_tags and the provider's default_tags)"
type = map(string)
nullable = false
}
#------------------------------------------------
## ec2 instance config for web servers managed by ASG (they get deployed in the public subnets)
#------------------------------------------------
variable "asg_launch_config" {
type = object({
name_prefix = string
image_id = string
instance_type = string
user_data_file_path = string
associate_public_ip_address = bool
})
default = {
name_prefix = "web-"
image_id = "ami-0df4b2961410d4cff"
instance_type = "t2.micro"
user_data_file_path = "user-data.sh"
associate_public_ip_address = true
}
}
#------------------------------------------------
## ec2 instance config for bastion host and its key pair (it is automatically deployed to the first_public_subnet of the vpc)
#------------------------------------------------
variable "bastion_ami" {
type = string
default = "ami-0df4b2961410d4cff"
}
variable "bastion_instance_type" {
type = string
default = "t2.micro"
}
variable "key_pair_public" {
description = "Provide public key of your ssh key pair to be used for bastion hosts and web servers. The value will not be shown as it is set as sensitive."
type = string
sensitive = true
nullable = false
}
#------------------------------------------------
## auto scaling
#------------------------------------------------
variable "asg" {
type = object({
name = string
max_size = number
min_size = number
desired_capacity = number
})
default = {
name = "web"
max_size = 3
min_size = 1
desired_capacity = 2
}
}
variable "asg_policy" {
type = object({
policy_type = string
estimated_instance_warmup = number
})
default = {
policy_type = "TargetTrackingScaling"
estimated_instance_warmup = 30
}
}
variable "asg_policy_target_config_metric" {
type = string
default = "ASGAverageCPUUtilization"
}
variable "asg_policy_target_config_value" {
type = number
default = 80
}