-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2.tf
70 lines (60 loc) · 1.61 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
resource "aws_key_pair" "deployer" {
key_name = "deployer"
public_key = file("~/.ssh/id_rsa.pub")
}
data "aws_ami" "ubuntu_nginx" {
owners = ["self"]
most_recent = true
filter {
name = "name"
values = ["ubuntu-nginx"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
}
data "aws_ami" "ubuntu_base" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"]
}
resource "aws_instance" "web" {
subnet_id = aws_subnet.private1.id
vpc_security_group_ids = [aws_security_group.allow_http.id, aws_security_group.allow_ssh.id]
ami = data.aws_ami.ubuntu_nginx.id
instance_type = "t2.micro"
user_data = file("init.yaml")
key_name = aws_key_pair.deployer.key_name
root_block_device {
volume_type = "gp2"
volume_size = "8"
delete_on_termination = true
}
tags = {
Name = "web"
}
}
resource "aws_instance" "bastion" {
subnet_id = aws_subnet.public1.id
vpc_security_group_ids = [aws_security_group.allow_ssh.id]
associate_public_ip_address = true
ami = data.aws_ami.ubuntu_base.id
instance_type = "t2.micro"
key_name = aws_key_pair.deployer.key_name
root_block_device {
volume_type = "gp2"
volume_size = "8"
delete_on_termination = true
}
tags = {
Name = "bastion"
}
}