-
Notifications
You must be signed in to change notification settings - Fork 1
/
eks.tf
96 lines (82 loc) · 2.5 KB
/
eks.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
# EKS cluster
module "eks" {
source = "registry.terraform.io/terraform-aws-modules/eks/aws"
version = "18.26.6"
cluster_name = local.name
cluster_version = var.k8s_version
subnet_ids = concat(module.vpc.private_subnets, module.vpc.public_subnets)
vpc_id = module.vpc.vpc_id
enable_irsa = false
eks_managed_node_group_defaults = {}
create_cluster_security_group = false
cluster_security_group_id = aws_security_group.this.id
eks_managed_node_groups = {
default_group = {
min_size = 3
max_size = 3
desired_size = 3
labels = {}
vpc_security_group_ids = [aws_security_group.this.id]
instance_types = ["m5.large"]
metadata_options = {
http_endpoint = "enabled"
http_tokens = "optional"
http_put_response_hop_limit = 2
instance_metadata_tags = "disabled"
}
}
}
}
# Consul secrets for secure install
## ACLs - bootstrap token
resource "random_uuid" "bootstrap_token" {}
## Gossip encryption - gossip key
resource "random_id" "gossip_key" {
byte_length = 32
}
## TLS
### private key
resource "tls_private_key" "ca" {
algorithm = "ECDSA"
ecdsa_curve = "P384"
}
### CA cert
resource "tls_self_signed_cert" "ca" {
private_key_pem = tls_private_key.ca.private_key_pem
subject {
common_name = "Consul Agent CA"
organization = "HashiCorp Inc."
}
// 5 years.
validity_period_hours = 43800
is_ca_certificate = true
set_subject_key_id = true
allowed_uses = [
"digital_signature",
"cert_signing",
"crl_signing",
]
}
resource "kubernetes_secret" "consul_secrets" {
metadata {
name = var.consul_secrets_name
}
data = {
license = local.consul_license
caKey = tls_private_key.ca.private_key_pem
caCert = tls_self_signed_cert.ca.cert_pem
gossipEncryptionKey = random_id.gossip_key.b64_std
bootstrapToken = random_uuid.bootstrap_token.result
}
type = "Opaque"
}
resource "local_file" "consul_values_yaml" {
filename = "values.yaml"
file_permission = "0644"
content = templatefile("values.yaml.tftpl", {
consul_image = var.consul_image
datacenter = var.consul_datacenter
is_enterprise = local.is_enterprise
secret_name = var.consul_secrets_name
})
}