-
Notifications
You must be signed in to change notification settings - Fork 0
/
bastinhost.tf
56 lines (40 loc) · 1013 Bytes
/
bastinhost.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
resource "aws_instance" "bastion" {
## Ubuntu 18 LTS AMI
ami = "ami-074251216af698218"
key_name = aws_key_pair.ssh_key.id
instance_type = "t2.micro"
security_groups = [aws_security_group.bastion-sg.id]
#associate_public_ip_address = true
subnet_id = module.vpc.public_subnets[0]
}
resource "aws_ec2_tag" "bastiantag" {
resource_id = aws_instance.bastion.id
key = "Name"
value = "Bastian_Server"
}
resource "aws_eip" "bas_ip" {
vpc = true
tags = {
Name = "bastian_eip"
}
}
resource "aws_eip_association" "eip_assoc" {
instance_id = aws_instance.bastion.id
allocation_id = aws_eip.bas_ip.id
}
resource "aws_security_group" "bastion-sg" {
name = "bastion-security-group"
vpc_id = module.vpc.vpc_id
ingress {
protocol = "tcp"
from_port = 22
to_port = 22
cidr_blocks = ["0.0.0.0/0"]
}
egress {
protocol = -1
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}