Skip to content

Commit 77cdd87

Browse files
committed
bug fixes
1 parent 604898a commit 77cdd87

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

terraform-aws-private-public-ip/variables.tf

+39
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,46 @@ variable "instance_type" {
1515
default = "t2.micro"
1616
}
1717

18+
variable "device_name" {
19+
type = "string"
20+
default = "/dev/xvdh"
21+
}
1822
variable "key_name" {
1923
type = "string"
2024
default = "ec2-demo"
2125
}
26+
27+
variable "cidr" {
28+
description = "The CIDR block for the VPC. Default value is a valid CIDR, but not acceptable by AWS and should be overridden"
29+
type = string
30+
default = "10.0.0.0/16"
31+
}
32+
variable "instance_tenancy" {
33+
description = "A tenancy option for instances launched into the VPC"
34+
type = string
35+
default = "default"
36+
}
37+
38+
variable "enable_dns_hostnames" {
39+
description = "Should be true to enable DNS hostnames in the VPC"
40+
type = bool
41+
default = true
42+
}
43+
44+
variable "enable_dns_support" {
45+
description = "Should be true to enable DNS support in the VPC"
46+
type = bool
47+
default = true
48+
}
49+
50+
variable "enable_classiclink" {
51+
description = "Should be true to enable ClassicLink for the VPC. Only valid in regions and accounts that support EC2 Classic."
52+
type = bool
53+
default = false
54+
}
55+
56+
variable "tags" {
57+
description = "A map of tags to add to all resources"
58+
type = string
59+
default = "Vpc-custom-demo"
60+
}
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
resource "aws_vpc" "vpc_demo" {
2+
cidr_block = var.cidr
3+
instance_tenancy = var.instance_tenancy
4+
enable_dns_hostnames = var.enable_dns_hostnames
5+
enable_dns_support = var.enable_dns_support
6+
enable_classiclink = var.enable_classiclink
7+
8+
tags = {
9+
Name = var.tags
10+
}
11+
}
12+
13+
resource "aws_internet_gateway" "gw" {
14+
vpc_id = aws_vpc.vpc_demo.id
15+
16+
tags = {
17+
Name = "internet-gateway-demo"
18+
}
19+
}
20+
21+
resource "aws_subnet" "public_1" {
22+
availability_zone = "us-east-1a"
23+
vpc_id = aws_vpc.vpc_demo.id
24+
map_public_ip_on_launch = true
25+
cidr_block = "10.0.1.0/24"
26+
27+
tags = {
28+
Name = "public_1-demo"
29+
}
30+
}
31+
32+
resource "aws_route_table" "route-public" {
33+
vpc_id = aws_vpc.vpc_demo.id
34+
35+
route {
36+
cidr_block = "10.0.0.0/0"
37+
gateway_id = aws_internet_gateway.gw.id
38+
}
39+
40+
tags = {
41+
Name = "public-route-table-demo"
42+
}
43+
}
44+
45+
resource "aws_route_table_association" "public_1" {
46+
subnet_id = aws_subnet.public_1.id
47+
route_table_id = aws_route_table.route-public.id
48+
}
49+
50+
resource "aws_security_group" "allow_ssh" {
51+
name = "allow_SSH"
52+
description = "Allow SSH inbound traffic"
53+
vpc_id = aws_vpc.vpc_demo.id
54+
55+
ingress {
56+
# SSH Port 22 allowed from any IP
57+
from_port = 22
58+
to_port = 22
59+
protocol = "tcp"
60+
cidr_blocks = ["0.0.0.0/0"]
61+
}
62+
63+
ingress {
64+
# SSH Port 80 allowed from any IP
65+
from_port = 80
66+
to_port = 80
67+
protocol = "tcp"
68+
cidr_blocks = ["0.0.0.0/0"]
69+
}
70+
71+
egress {
72+
from_port = 0
73+
to_port = 0
74+
protocol = "-1"
75+
cidr_blocks = ["0.0.0.0/0"]
76+
}
77+
}

0 commit comments

Comments
 (0)