-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
55 lines (48 loc) · 1.2 KB
/
main.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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
# Configure the AWS Provider
provider "aws" {
region = "ap-southeast-1"
access_key = "enter your aws access key"
secret_key = "enter your aws secret key"
}
# Create a VPC
resource "aws_vpc" "main_vpc" {
cidr_block = "18.0.0.0/20"
}
# Create subnet (1a)
resource "aws_subnet" "public_subnet_one" {
vpc_id = aws_vpc.main_vpc.id
cidr_block = "18.0.0.0/23"
availability_zone = "ap-southeast-1a"
map_public_ip_on_launch = true
}
resource "aws_subnet" "private_subnet_one" {
vpc_id = aws_vpc.main_vpc.id
cidr_block = "18.0.2.0/23"
availability_zone = "ap-southeast-1a"
map_public_ip_on_launch = false
}
# Create subnet (1b)
resource "aws_subnet" "public_subnet_two" {
vpc_id = aws_vpc.main_vpc.id
cidr_block = "18.0.4.0/23"
availability_zone = "ap-southeast-1b"
map_public_ip_on_launch = true
}
resource "aws_subnet" "private_subnet_two" {
vpc_id = aws_vpc.main_vpc.id
cidr_block = "18.0.6.0/23"
availability_zone = "ap-southeast-1b"
map_public_ip_on_launch = false
}
# Create IGW
resource "aws_internet_gateway" "gw" {
vpc_id = aws_vpc.main_vpc.id
}