-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2.tf
50 lines (45 loc) · 1.21 KB
/
ec2.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
module "aws_key_pair" {
providers = {
aws = aws.provisionaccount
}
source = "cloudposse/key-pair/aws"
version = "0.20.0"
generate_ssh_key = true
name = "ec2"
namespace = terraform.workspace
ssh_public_key_path = var.ssh_public_key_path
}
module "ec2" {
providers = {
aws = aws.provisionaccount
}
source = "cloudposse/ec2-instance/aws"
version = "1.6.1"
associate_public_ip_address = true
instance_type = "t3.micro"
name = "ec2"
namespace = terraform.workspace
security_group_rules = [
# Allow ingress from trusted CIDR blocks
{
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = var.ec2_trusted_ingress_cidr_blocks
},
# Allow egress anywhere
{
type = "egress"
from_port = 0
to_port = 65535
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
},
]
ssh_key_pair = module.aws_key_pair.key_name
subnet = module.subnets.public_subnet_ids[0]
tags = var.tags
volume_tags_enabled = false
vpc_id = module.vpc.vpc_id
}