-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
52 lines (44 loc) · 1 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
provider "aws" {
region = "eu-west-3"
}
variable cidr_blocks {
description = "cidr blocks and name tags for vpc and subnets"
type = list(object({
cidr_block = string
name = string
}))
}
variable avail_zone {
default = "eu-west-3a"
}
resource "aws_vpc" "myapp-vpc" {
cidr_block = var.cidr_blocks[0].cidr_block
tags = {
Name = var.cidr_blocks[0].name
}
}
resource "aws_subnet" "myapp-subnet-1" {
vpc_id = aws_vpc.myapp-vpc.id
cidr_block = var.cidr_blocks[1].cidr_block
availability_zone = var.avail_zone
tags = {
Name = var.cidr_blocks[1].name
}
}
output "dev-vpc-id" {
value = aws_vpc.development-vpc.id
}
output "dev-subnet-id" {
value = aws_subnet.dev-subnet-1.id
}
data "aws_vpc" "existing_vpc" {
default = true
}
resource "aws_subnet" "dev-subnet-2" {
vpc_id = data.aws_vpc.existing_vpc.id
cidr_block = "172.31.48.0/20"
availability_zone = "eu-west-3a"
tags = {
Name = "subnet-2-default"
}
}