-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
62 lines (50 loc) · 1.19 KB
/
main.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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
variable "region" {
type = string
default = "us-east-1"
validation {
condition = length(var.region) > 0
error_message = "Region has to be specified."
}
}
variable "ami" {
type = string
default = "ami-0c582118883b46f4f"
validation {
condition = length(var.ami) > 4 && substr(var.ami, 0, 4) == "ami-"
error_message = "AMI has to be specified and has to have an 'ami-' prefix."
}
}
variable "spot_price" {
type = number
validation {
condition = var.spot_price > 0
error_message = "Spot price has to be provided and be greater than 0."
}
}
variable "key_name" {
type = string
validation {
condition = length(var.key_name) > 0
error_message = "Key name has to be specified."
}
}
variable "capacity" {
type = number
validation {
condition = var.capacity > 0
error_message = "Capacity has to be specified and be greater than 0."
}
}
// -----------------------------------------------------------------------------
# Configure the AWS Provider
provider "aws" {
region = var.region
}