-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec2.tf
More file actions
62 lines (53 loc) · 1.45 KB
/
Copy pathec2.tf
File metadata and controls
62 lines (53 loc) · 1.45 KB
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
resource "aws_kms_key" "ebs" {
description = "KMS key for EBS encryption"
deletion_window_in_days = 10
enable_key_rotation = true
tags = merge(var.common_tags, {
Name = "EBS Encryption Key"
})
}
resource "aws_instance" "secure_ec2" {
ami = var.ami_id
instance_type = var.instance_type
associate_public_ip_address = false
subnet_id = aws_subnet.private[0].id
vpc_security_group_ids = [aws_security_group.web_sg.id]
iam_instance_profile = aws_iam_instance_profile.ec2_profile.name
monitoring = true
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = 1
}
root_block_device {
volume_size = 20
volume_type = "gp3"
encrypted = true
kms_key_id = aws_kms_key.ebs.arn
}
ebs_block_device {
device_name = "/dev/sdf"
volume_size = 50
volume_type = "gp3"
encrypted = true
kms_key_id = aws_kms_key.ebs.arn
}
ebs_block_device {
device_name = "/dev/sdg"
volume_size = 100
volume_type = "gp3"
encrypted = true
kms_key_id = aws_kms_key.ebs.arn
}
tags = merge(
var.common_tags,
{
Name = "Web production server"
}
)
}
resource "aws_lb_target_group_attachment" "web" {
target_group_arn = aws_lb_target_group.web.arn
target_id = aws_instance.secure_ec2.id
port = 80
}