Following aws vpc course from https://github.com/Lowess
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
955 B
47 lines
955 B
### Module Main
|
|
|
|
provider "aws" {
|
|
region = var.aws_region
|
|
}
|
|
|
|
resource "aws_vpc" "main" {
|
|
cidr_block = var.vpc_cidr
|
|
|
|
tags = {
|
|
Name = "${var.vpc_name}-vpc",
|
|
Terraform = true,
|
|
Environment = "production"
|
|
}
|
|
}
|
|
|
|
## Fonction super utile pour le calc de ss réseaux
|
|
# cidrsubnet("172.22.0.0/16",4,iterate_value)
|
|
|
|
resource "aws_subnet" "private" {
|
|
for_each = var.azs
|
|
|
|
vpc_id = aws_vpc.main.id
|
|
cidr_block = cidrsubnet(var.vpc_cidr, 4, each.value)
|
|
availability_zone = "${var.aws_region}${each.key}"
|
|
|
|
map_public_ip_on_launch = false
|
|
|
|
tags = {
|
|
Name = "${var.vpc_name}-private-${var.aws_region}${each.key}"
|
|
}
|
|
}
|
|
|
|
resource "aws_subnet" "public" {
|
|
for_each = var.azs
|
|
|
|
vpc_id = aws_vpc.main.id
|
|
cidr_block = cidrsubnet(var.vpc_cidr, 4, 15 - each.value)
|
|
availability_zone = "${var.aws_region}${each.key}"
|
|
|
|
map_public_ip_on_launch = true
|
|
|
|
tags = {
|
|
Name = "${var.vpc_name}-public-${var.aws_region}${each.key}"
|
|
}
|
|
}
|
|
|
|
|