File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,19 @@ locals {
8
8
nat_gateway_count = var. single_nat_gateway ? 1 : var. one_nat_gateway_per_az ? length (var. azs ) : local. max_subnet_length
9
9
10
10
# Use `local.vpc_id` to give a hint to Terraform that subnets should be deleted before secondary CIDR blocks can be free!
11
- vpc_id = element (
11
+ vpc_id = var . create_vpc ? element (
12
12
concat (
13
13
aws_vpc_ipv4_cidr_block_association. this . * . vpc_id ,
14
14
aws_vpc. this . * . id ,
15
15
[" " ],
16
16
),
17
17
0 ,
18
- )
18
+ ) : data. aws_vpc . vpc . id
19
+ }
20
+
21
+ data "aws_vpc" "vpc" {
22
+ count = var. create_vpc ? 0 : 1
23
+ id = var. vpc_id
19
24
}
20
25
21
26
# #####
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ variable "create_vpc" {
4
4
default = true
5
5
}
6
6
7
+ variable "vpc_id" {
8
+ description = " VPC id for use in cases where VPC was already created and you would like to reuse it with this module. Not required if create_vpc = true"
9
+ type = string
10
+ default = " "
11
+ }
12
+
7
13
variable "name" {
8
14
description = " Name to be used on all the resources as identifier"
9
15
default = " "
You can’t perform that action at this time.
0 commit comments