-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
48 lines (39 loc) · 848 Bytes
/
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
provider "aws" {
region = "eu-west-3"
}
variable "subnet_cidr_blocks" {
description = "Subnet cidr blocks"
type = list(string)
}
variable "vpc_cidr_block" {
description = "VPC cidr block"
type = string
}
resource "aws_vpc" "my_vpc" {
cidr_block = var.vpc_cidr_block
tags = {
Name: "Terraform-made"
}
}
resource "aws_subnet" "subnet-1" {
vpc_id= aws_vpc.my_vpc.id
cidr_block = var.subnet_cidr_blocks[0]
availability_zone = "eu-west-3a"
}
data "aws_vpc" "existing_vpc" {
default = true
}
resource "aws_subnet" "subnet-2" {
vpc_id = data.aws_vpc.existing_vpc.id
cidr_block = "172.31.200.0/24"
availability_zone = "eu-west-3b"
tags = {
Name: "Terraform-made-subnet"
}
}
output "vpc-id" {
value = aws_vpc.my_vpc.id
}
output "subnet-id" {
value = aws_subnet.subnet-1.id
}