-
Notifications
You must be signed in to change notification settings - Fork 43
/
terraform.tf
121 lines (91 loc) · 2.13 KB
/
terraform.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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.67.0"
}
}
}
locals {
tags = {
Project = "perf"
}
}
provider "aws" {
alias = "us-west-2"
region = "us-west-2"
default_tags {
tags = local.tags
}
}
provider "aws" {
alias = "us-east-1"
region = "us-east-1"
default_tags {
tags = local.tags
}
}
variable "ci_enabled" {
type = bool
description = "Whether or not to create resources required to automate the setup in CI (e.g. IAM user, cleanup Lambda)"
default = false
}
variable "long_lived_enabled" {
type = bool
description = "Whether or not to create long lived resources (in CI, used across runs; e.g. VPCs)"
default = false
}
variable "short_lived_enabled" {
type = bool
description = "Whether or not to create short lived resources (in CI, specific to each run; e.g. EC2 instances)"
default = true
}
module "ci" {
count = var.ci_enabled ? 1 : 0
source = "../../modules/ci"
regions = ["us-west-2", "us-east-1"]
tags = local.tags
providers = {
aws = aws.us-west-2
}
}
module "long_lived_server" {
count = var.long_lived_enabled ? 1 : 0
source = "../../modules/long_lived"
region = "us-west-2"
ami = "ami-002829755fa238bfa"
providers = {
aws = aws.us-west-2
}
}
module "long_lived_client" {
count = var.long_lived_enabled ? 1 : 0
source = "../../modules/long_lived"
region = "us-east-1"
ami = "ami-051f7e7f6c2f40dc1"
providers = {
aws = aws.us-east-1
}
}
module "short_lived_server" {
count = var.short_lived_enabled ? 1 : 0
source = "../../modules/short_lived"
providers = {
aws = aws.us-west-2
}
depends_on = [module.long_lived_server]
}
module "short_lived_client" {
count = var.short_lived_enabled ? 1 : 0
source = "../../modules/short_lived"
providers = {
aws = aws.us-east-1
}
depends_on = [module.long_lived_client]
}
output "client_ip" {
value = var.short_lived_enabled ? module.short_lived_client[0].public_ip : null
}
output "server_ip" {
value = var.short_lived_enabled ? module.short_lived_server[0].public_ip : null
}