-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
61 lines (52 loc) · 1.81 KB
/
Copy pathmain.tf
File metadata and controls
61 lines (52 loc) · 1.81 KB
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
# Contains the main resource block for creating the Red Network
# Main VPC Resource
# Justification: Flow logs are available opt-in via var.enable_flow_logs. When disabled
# (the default), no flow log is created and this finding is accepted for
# the module's baseline networking role.
# trivy:ignore:AVD-AWS-0178
resource "aws_vpc" "main" {
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
enable_dns_support = true
tags = merge(
local.tags,
{
Name = var.vpc_name
}
)
}
####################################################################################################
# Subnets
####################################################################################################
# Justification: Public IP assignment is the defining behavior of a subnet the caller has
# explicitly declared as type = "public"; private subnets receive false.
# The caller controls which subnets are public via var.subnets.
# trivy:ignore:AVD-AWS-0164
resource "aws_subnet" "subnets" {
for_each = var.subnets
vpc_id = aws_vpc.main.id
cidr_block = each.value.cidr_block
availability_zone = each.value.availability_zone
map_public_ip_on_launch = each.value.type == "public" ? true : false
tags = merge(
local.tags,
{
Name = each.value.name
Type = each.value.type
}
)
}
####################################################################################################
# VPC Endpoints
####################################################################################################
# S3 VPC Endpoint (Gateway)
resource "aws_vpc_endpoint" "s3" {
vpc_id = aws_vpc.main.id
service_name = "com.amazonaws.${data.aws_region.current.region}.s3"
tags = merge(
local.tags,
{
Name = "${var.vpc_name}-s3-endpoint"
}
)
}