-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathmain.tf
166 lines (152 loc) · 4.21 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
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
163
164
165
166
### Machine Learning with Kubeflow
terraform {
required_version = "~> 1.0"
}
provider "aws" {
region = var.aws_region
}
### aws partitions
module "aws" {
source = "Young-ook/spinnaker/aws//modules/aws-partitions"
}
locals {
aws = {
dns = module.aws.partition.dns_suffix
region = module.aws.region.name
}
}
### vpc
module "vpc" {
source = "Young-ook/vpc/aws"
version = "1.0.7"
name = var.name
tags = var.tags
vpc_config = {
azs = var.azs
cidr = "10.10.0.0/16"
subnet_type = "private"
single_ngw = true
}
}
### eks
module "eks" {
source = "Young-ook/eks/aws"
version = "2.1.0"
name = var.name
tags = var.tags
subnets = slice(values(module.vpc.subnets["private"]), 0, 3)
enable_ssm = true
kubernetes_version = var.kubernetes_version
managed_node_groups = [
{
name = "ml"
min_size = 1
max_size = 9
desired_size = 6
instance_type = "t3.xlarge"
}
]
}
### kubeflow-manifests
resource "null_resource" "clone" {
for_each = (try(local.toggles.kubeflow_enabled, false) ? toset(["kubeflow"]) : [])
provisioner "local-exec" {
command = "bash scripts/clone.sh -k $KUBEFLOW_RELEASE_VERSION -a $AWS_RELEASE_VERSION"
environment = {
KUBEFLOW_RELEASE_VERSION = "v1.6.1"
AWS_RELEASE_VERSION = "v1.6.1-aws-b1.0.0"
}
}
}
resource "null_resource" "clear" {
depends_on = [module.kubeflow, null_resource.clone]
for_each = (try(local.toggles.kubeflow_enabled, false) ? toset(["kubeflow"]) : [])
provisioner "local-exec" {
command = "rm -rf kubeflow-manifests"
}
}
### helm-addons
provider "helm" {
kubernetes {
host = module.eks.kubeauth.host
token = module.eks.kubeauth.token
cluster_ca_certificate = module.eks.kubeauth.ca
}
}
module "kubeflow" {
depends_on = [module.csi, null_resource.clone]
for_each = (try(local.toggles.kubeflow_enabled, false) ? toset(["enabled"]) : [])
source = "./modules/kubeflow"
tags = var.tags
kubeflow_helm_repo = var.kubeflow_helm_repo
}
module "airflow" {
depends_on = [module.csi]
for_each = (try(local.toggles.airflow_enabled, false) ? toset(["enabled"]) : [])
source = "Young-ook/eks/aws//modules/helm-addons"
version = "2.0.11"
tags = var.tags
addons = [
{
### for more details, https://airflow.apache.org/docs/helm-chart/stable/index.html
repository = "https://airflow.apache.org"
name = "airflow"
chart_name = "airflow"
chart_version = "1.7.0"
namespace = "airflow"
serviceaccount = "airflow"
### since airflow migration process, need to turn off waiting of the terraform helm release
### for more details, https://github.com/hashicorp/terraform-provider-helm/issues/742
wait = false
},
]
}
### stoage
module "s3" {
source = "Young-ook/sagemaker/aws//modules/s3"
version = "0.4.7"
tags = var.tags
force_destroy = true
lifecycle_rules = [
{
id = "s3-intelligent-tiering"
status = "Enabled"
filter = {
prefix = ""
}
transition = [
{
days = 0
storage_class = "INTELLIGENT_TIERING"
},
]
},
]
}
### eks-addons
module "csi" {
depends_on = [module.eks]
source = "Young-ook/eks/aws//modules/eks-addons"
version = "2.0.11"
tags = var.tags
addons = [
{
name = "aws-ebs-csi-driver"
namespace = "kube-system"
serviceaccount = "ebs-csi-controller-sa"
eks_name = module.eks.cluster.name
oidc = module.eks.oidc
policy_arns = [
format("arn:%s:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy", module.aws.partition.partition),
]
},
{
name = "aws-mountpoint-s3-csi-driver"
namespace = "kube-system"
serviceaccount = "s3-csi-driver-sa"
eks_name = module.eks.cluster.name
oidc = module.eks.oidc
policy_arns = [module.s3.policy_arns["read"], module.s3.policy_arns["write"]]
},
]
}