-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
71 lines (58 loc) · 1.15 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
67
68
69
70
71
#
# Provider
#
provider "aws" {}
#
# Variables
#
variable cidr_blocks {
description = "cidr blocks and name tags for vpc and subnets"
type = list(object({
cidr_block = string
name = string
}))
}
#
# Environemnt variables
#
variable "avail_zone" {}
#
# Resources
#
resource "aws_vpc" "cluster-vpc" {
cidr_block = var.cidr_blocks[0].cidr_block
tags = {
Name = var.cidr_blocks[0].name
}
}
resource "aws_subnet" "cluster-subnet-1" {
vpc_id = aws_vpc.cluster-vpc.id
cidr_block = var.cidr_blocks[1].cidr_block
#availability_zone = var.avail_zone
tags = {
Name = var.cidr_blocks[1].name
}
}
data "aws_vpc" "Existing-vpc" {
default = true
}
resource "aws_subnet" "cluster-subnet-2" {
vpc_id = data.aws_vpc.Existing-vpc.id
cidr_block = var.cidr_blocks[2].cidr_block
availability_zone = var.avail_zone
tags = {
Name = "cluster-subnet-2"
}
}
#
# Outputs
#
output "clutser-vpc" {
value = aws_vpc.cluster-vpc.id
}
output "cluster-subnet-1_id" {
value = aws_subnet.cluster-subnet-1.id
}
output "cluster-subnet-2_id" {
value = aws_subnet.cluster-subnet-2.id
}