forked from Young-ook/terraform-aws-spinnaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
49 lines (43 loc) · 1.56 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
# current region
data "aws_region" "current" {}
locals {
alias_region = substr(data.aws_region.current.name, 0, 2) == "cn" ? ".cn" : ""
alias_service = format("amazonaws.com%s", local.alias_region)
}
# name and description
locals {
name = join("-", compact([var.name, var.stack, var.detail, local.suffix]))
cluster-name = local.name
eks-name = join("-", compact([local.cluster-name, "eks"]))
nodes-name = join("-", compact([local.cluster-name, "nodes"]))
suffix = random_string.suffix.result
}
resource "random_string" "suffix" {
length = 4
upper = false
lower = true
number = false
special = false
}
# vpc tags
locals {
vpc-name-tag = { "Name" = join("-", compact([local.name, "vpc"])) }
igw-name-tag = { "Name" = join("-", compact([local.name, "igw"])) }
ngw-name-tag = { "Name" = join("-", compact([local.name, "ngw"])) }
public-route-name-tag = { "Name" = join("-", compact([local.name, "public-route"])) }
private-route-name-tag = { "Name" = join("-", compact([local.name, "private-route"])) }
private-dns-name-tag = { "Name" = join("-", compact([local.name, "private-dns"])) }
}
# kubernetes tags
locals {
eks-name-tag = { "Name" = local.eks-name }
nodes-name-tag = { "Name" = local.nodes-name }
vpc-k8s-shared-tag = {
format("kubernetes.io/cluster/%s", local.cluster-name) = "shared"
}
vpc-k8s-owned-tag = {
"key" = format("kubernetes.io/cluster/%s", local.cluster-name)
"value" = "owned"
"propagate_at_launch" = "true"
}
}