-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript
More file actions
59 lines (59 loc) · 1.15 KB
/
script
File metadata and controls
59 lines (59 loc) · 1.15 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
provider "aws" {
region = var.region
}
resource "aws_vpc" "default" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "default"
}
}
resource "aws_subnet" "private" {
vpc_id = aws_vpc.default.id
cidr_block = "10.0.0.0/24"
availability_zone = "us-east-1a"
tags = {
Name = "private"
}
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.default.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-east-1b"
tags = {
Name = "public"
}
}
resource "aws_instance" "default" {
ami = "ami-03b2b851552066568"
instance_type = "t2.micro"
subnet_id = aws_subnet.public.id
vpc_security_group_ids = [aws_security_group.default.id]
tags = {
Name = "default"
purpose = "Assignment"
}
root_block_device {
volume_size = 8
volume_type = "gp2"
encrypted = false
}
}
resource "aws_security_group" "default" {
name = "default"
vpc_id = aws_vpc.default.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"]
}
}
output "public_ip" {
value = aws_instance.default.public_ip
}