Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit 35ec720

Browse files
committed
initial migration from batcave-landing-zone
0 parents  commit 35ec720

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

main.tf

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# vpc id
2+
data "aws_vpc" "batcave_vpc" {
3+
tags = {
4+
Name = "batcave-*-${var.env}"
5+
}
6+
}
7+
8+
# private subnets
9+
data "aws_subnet_ids" "private" {
10+
vpc_id = data.aws_vpc.batcave_vpc.id
11+
filter {
12+
name = "tag:Name"
13+
values = [
14+
"batcave-*-${var.env}-private-*"
15+
]
16+
}
17+
}
18+
19+
# public subnets
20+
data "aws_subnet_ids" "public" {
21+
vpc_id = data.aws_vpc.batcave_vpc.id
22+
filter {
23+
name = "tag:Name"
24+
values = [
25+
"batcave-*-${var.env}-public-*"
26+
]
27+
}
28+
}
29+
30+
# container subnets
31+
data "aws_subnet_ids" "container" {
32+
vpc_id = data.aws_vpc.batcave_vpc.id
33+
filter {
34+
name = "tag:Name"
35+
values = [
36+
"batcave-*-${var.env}-unroutable-*"
37+
]
38+
}
39+
}
40+
41+
# transport subnets
42+
data "aws_subnet_ids" "transport" {
43+
count = var.transport_subnets_exist ? 1 : 0
44+
vpc_id = data.aws_vpc.batcave_vpc.id
45+
filter {
46+
name = "tag:Name"
47+
values = [
48+
"batcave-*-${var.env}-transport-*"
49+
]
50+
}
51+
}
52+
53+
## subnet resources
54+
data "aws_subnet" "private" {
55+
for_each = data.aws_subnet_ids.private.ids
56+
id = each.value
57+
}
58+
59+
data "aws_subnet" "public" {
60+
for_each = data.aws_subnet_ids.public.ids
61+
id = each.value
62+
}
63+
64+
data "aws_subnet" "container" {
65+
for_each = data.aws_subnet_ids.container.ids
66+
id = each.value
67+
}
68+
69+
data "aws_subnet" "transport" {
70+
for_each = try(data.aws_subnet_ids.transport[0].ids, toset([]))
71+
id = each.value
72+
}
73+
74+
data "aws_security_group" "shared_services_sg" {
75+
vpc_id = data.aws_vpc.batcave_vpc.id
76+
filter {
77+
name = "tag:Name"
78+
values = [
79+
"cmscloud-shared-services"
80+
]
81+
}
82+
}
83+
84+
data "aws_security_group" "cmscloud_vpn" {
85+
vpc_id = data.aws_vpc.batcave_vpc.id
86+
filter {
87+
name = "tag:Name"
88+
values = [
89+
"cmscloud-vpn"
90+
]
91+
}
92+
}
93+
94+
data "aws_ec2_managed_prefix_list" "vpn_prefix_list" {
95+
name = "cmscloud-vpn"
96+
}
97+
98+
data "aws_ec2_managed_prefix_list" "cmscloud_shared_services_pl"{
99+
name = "cmscloud-shared-services"
100+
}
101+

outputs.tf

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## VPC Data
2+
3+
output "vpc" {
4+
value = data.aws_vpc.batcave_vpc.cidr_block_associations.*.cidr_block
5+
}
6+
7+
output "vpc_id" {
8+
description = "The ID of the VPC"
9+
value = data.aws_vpc.batcave_vpc.id
10+
}
11+
12+
output "vpc_arn" {
13+
description = "The ARN of the VPC"
14+
value = data.aws_vpc.batcave_vpc.arn
15+
}
16+
17+
18+
output "private_subnets" {
19+
description = "List of IDs of private subnets"
20+
value = data.aws_subnet_ids.private.ids
21+
}
22+
23+
output "public_subnets" {
24+
description = "List of IDs of public subnets"
25+
value = data.aws_subnet_ids.public.ids
26+
}
27+
28+
output "container_subnets" {
29+
description = "List of IDs of container subnets"
30+
value = data.aws_subnet_ids.container.ids
31+
}
32+
33+
output "transport_subnets" {
34+
description = "List of IDs of transport subnets"
35+
value = try(data.aws_subnet_ids.transport[0].ids, [])
36+
}
37+
output "transport_subnet_cidr_blocks" {
38+
description = "map of IDs to transport subnet cidrs"
39+
value = { for subnet in data.aws_subnet.transport : subnet.id => subnet.cidr_block }
40+
}
41+
42+
output "shared_services_sg" {
43+
description = "ID of the shared services security group"
44+
value = data.aws_security_group.shared_services_sg.id
45+
}
46+
47+
output "cmscloud_vpn_sg" {
48+
description = "ID of the cmscloud vpn security group"
49+
value = data.aws_security_group.cmscloud_vpn.id
50+
}
51+
52+
output "cmscloud_vpn_pl" {
53+
description = "Prefix list of cmscloud vpn"
54+
value = data.aws_ec2_managed_prefix_list.vpn_prefix_list.id
55+
}
56+
57+
output "cmscloud_shared_services_pl" {
58+
value = data.aws_ec2_managed_prefix_list.cmscloud_shared_services_pl.id
59+
}

variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "env" {
2+
default = "dev"
3+
}
4+
5+
variable "transport_subnets_exist" {
6+
description = "Transport subnets are used to house the NLB in situations where a service is required to be exposed to VDI users"
7+
default = false
8+
type = bool
9+
}

0 commit comments

Comments
 (0)