-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
103 lines (79 loc) · 2.01 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
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
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
data "aws_route53_zone" "tfe" {
name = var.route53_zone_name
}
data "aws_availability_zones" "all" {}
data "aws_ec2_instance_type_offering" "bastion" {
for_each = toset(data.aws_availability_zones.all.names)
filter {
name = "instance-type"
values = [var.ec2_bastion_instance_type]
}
filter {
name = "location"
values = [each.value]
}
location_type = "availability-zone"
}
data "aws_ec2_instance_type_offering" "tfe" {
for_each = toset(data.aws_availability_zones.all.names)
filter {
name = "instance-type"
values = [var.ec2_tfe_instance_type]
}
filter {
name = "location"
values = [each.value]
}
location_type = "availability-zone"
}
data "http" "myip" {
url = "http://ipv4.icanhazip.com"
}
data "aws_ami" "debian" {
most_recent = true
owners = ["136693071363"]
filter {
name = "name"
values = ["debian-12-amd64-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
name = "root-device-type"
values = ["ebs"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
}
data "aws_kms_key" "rds" {
key_id = "alias/aws/rds"
}
data "aws_kms_key" "secretsmanager" {
key_id = "alias/aws/secretsmanager"
}
data "aws_kms_key" "ssm" {
key_id = "alias/aws/ssm"
}
locals {
account_id = data.aws_caller_identity.current.account_id
region = data.aws_region.current.name
bucket_name = "${local.account_id}-${local.region}-terraform-enterprise"
my_ip = chomp(data.http.myip.response_body)
route53_alias_record_name = "${var.tfe_subdomain}.${var.route53_zone_name}"
}
resource "random_string" "tfe_encryption_password" {
length = 256
}
resource "random_string" "tfe_database_password" {
length = 64
}
resource "random_string" "tfe_redis_password" {
length = 128
special = false # The Redis auth token doesn't accept special characters.
}