-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathmain.tf
75 lines (59 loc) · 1.48 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
provider "aws" {
region = "eu-west-1"
}
module "iam_eks_role" {
source = "../../modules/iam-eks-role"
role_name = "my-app"
cluster_service_accounts = {
(random_pet.this.id) = ["default:my-app"]
}
tags = {
Name = "eks-role"
}
role_policy_arns = {
AmazonEKS_CNI_Policy = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
}
}
###############################
# IAM EKS role with self assume
###############################
module "iam_eks_role_with_self_assume" {
source = "../../modules/iam-eks-role"
role_name = "my-app-self-assume"
allow_self_assume_role = true
cluster_service_accounts = {
(random_pet.this.id) = ["default:my-app"]
}
tags = {
Name = "eks-role"
}
role_policy_arns = {
AmazonEKS_CNI_Policy = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
}
}
##################
# Extra resources
##################
resource "random_pet" "this" {
length = 2
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 18.0"
cluster_name = random_pet.this.id
cluster_version = "1.21"
vpc_id = data.aws_vpc.default.id
subnet_ids = data.aws_subnets.all.ids
}
##################################################################
# Data sources to get VPC, subnet, security group and AMI details
##################################################################
data "aws_vpc" "default" {
default = true
}
data "aws_subnets" "all" {
filter {
name = "vpc-id"
values = [data.aws_vpc.default.id]
}
}