-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
66 lines (52 loc) · 1.22 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
56
57
58
59
60
61
62
63
64
65
66
provider "aws" {
region = "ap-south-1"
}
variable "subnet-cidr-block" {
description = "Subnet cidr block"
default = "10.0.10.0/24"
type = string
}
variable "vpc-cidr-block" {
description = "VPC vidr block"
default = "10.0.0.0/16"
type = string
}
variable "environment" {
description = "Deployment Environment"
}
#! CREATING A VPC IN AWS
resource "aws_vpc" "development-vpc" {
cidr_block = var.vpc-cidr-block
tags = {
Name = var.environment
}
}
#! CREATING SUBNET IN ABOVE VPC
resource "aws_subnet" "devlopment-subnet-1" {
vpc_id = aws_vpc.development-vpc.id
cidr_block = var.subnet-cidr-block
availability_zone = "ap-south-1a"
tags = {
Name = "subnet-1-dev"
}
}
#! GETTING EXISTING RESOURCE IN AWS
# data "aws_vpc" "existing-vpc" {
# default = true
# }
#! CREATING SUBNET IN EXISTING VPC
# resource "aws_subnet" "devlopment-subnet-2" {
# vpc_id = data.aws_vpc.existing-vpc.id
# cidr_block = "172.31.48.0/20"
# availability_zone = "ap-south-1a"
# tags = {
# Name = "subnet-2-default"
# }
# }\
#! OUTPUT VARIABLES AFTER TERRAFORM APPLY
output "dev-vpc-id" {
value = aws_vpc.development-vpc.id
}
output "dev-subnet-id" {
value = aws_subnet.devlopment-subnet-1.id
}