-
Notifications
You must be signed in to change notification settings - Fork 483
/
Copy pathmain.tf
57 lines (47 loc) · 1.28 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
terraform {
required_version = "~> 1.3"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.46"
}
}
}
provider "aws" {
region = data.aws_region.current.id
alias = "default"
default_tags {
tags = local.tags
}
}
module "cluster" {
source = "./modules/cluster"
environment_name = local.environment_name
tags = local.tags
map_roles = concat(local.map_roles, [{
rolearn = aws_iam_role.local_role.arn
username = local.shell_role_name
groups = ["system:masters"]
}, {
# Did it this way because of circular dependencies
rolearn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${module.cluster.eks_cluster_id}-cloud9"
username = "cloud9"
groups = ["system:masters"]
}])
}
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
locals {
tags = {
created-by = "eks-workshop-v2"
env = local.environment_name
}
prefix = "eks-workshop"
environment_name = var.environment_suffix == "" ? local.prefix : "${local.prefix}-${var.environment_suffix}"
shell_role_name = "${local.environment_name}-shell-role"
map_roles = [for i, r in var.eks_role_arns : {
rolearn = r
username = "additional${i}"
groups = ["system:masters"]
}]
}