-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.tf
88 lines (75 loc) · 1.85 KB
/
stack.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
provider "aws" {
region = "us-west-2"
}
data "aws_ami" "eks_worker" {
filter {
name = "name"
values = ["amazon-eks-node-v1.21.2-*"]
}
most_recent = true
owners = ["602401143452"] # Amazon
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "2.77.0"
name = "my-vpc"
cidr = "10.0.0.0/16"
azs = ["us-west-2a", "us-west-2b", "us-west-2c"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
enable_nat_gateway = true
single_nat_gateway = true
enable_dns_hostnames = true
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = "my-eks-cluster"
cluster_version = "1.21"
subnets = module.vpc.private_subnets
node_groups = {
eks_nodes = {
desired_capacity = 2
max_capacity = 10
min_capacity = 1
instance_type = "t3.medium"
key_name = "my-key-name"
disk_size = 20
ami_id = data.aws_ami.eks_worker.id
additional_tags = {
Environment = "test"
Name = "eks-worker-node"
}
}
}
}
resource "aws_ebs_volume" "example" {
availability_zone = "us-west-2a"
size = 2000
tags = {
Name = "My_ebs_volume"
}
}
resource "aws_security_group" "example" {
name = "example"
description = "Example security group"
ingress {
description = "HTTPS"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
description = "SSH for git"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}