Created
December 16, 2015 18:10
-
-
Save conorgil/86db9825a62963967749 to your computer and use it in GitHub Desktop.
Terraform syntax bug in vpc peering module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# Variables | |
### | |
variable "vpc_id" { | |
description = "The id of the VPC" | |
} | |
variable "vpc_cidr" { | |
description = "The CIDR block of the VPC" | |
} | |
variable "vpc_route_table_ids" { | |
description = "A comma separated string of the IDs of the route tables in the VPC which should be updated to have a route for the VPC peering connection." | |
} | |
variable "peer_vpc_id" { | |
description = "The CIDR block of the peer VPC." | |
} | |
variable "peer_vpc_route_table_ids" { | |
description = "A comma separated string of the IDs of the route tables in the peer VPC which should be updated to have a route for the VPC peering connection." | |
} | |
variable "peer_vpc_cidr" { | |
description = "The CIDR block of the peer VPC." | |
} | |
variable "peer_owner_id" { | |
description = "The AWS account ID which owns the peer VPC." | |
} | |
### | |
# VPC peering connection | |
### | |
resource "aws_vpc_peering_connection" "main" { | |
auto_accept = true | |
vpc_id = "${var.vpc_id}" | |
peer_vpc_id = "${var.peer_vpc_id}" | |
peer_owner_id = "${var.peer_owner_id}" | |
} | |
### | |
# Update route tables | |
### | |
resource "aws_route" "vpc_to_peer_vpc" { | |
count = "${length(split(",", var.vpc_route_table_ids))}" | |
route_table_id = "${element(split(",", var.vpc_route_table_ids), count.index)}" | |
destination_cidr_block = "${var.peer_vpc_cidr}" | |
vpc_peering_connection_id = "${aws_vpc_peering_connection.main.id}" | |
} | |
resource "aws_route" "peer_vpc_to_vpc" { | |
count = "${length(split(",", var.peer_vpc_route_table_ids))}" | |
route_table_id = "${element(split(",", var.peer_vpc_route_table_ids), count.index)}" | |
destination_cidr_block = "${var.vpc_cidr}" | |
vpc_peering_connection_id = "${aws_vpc_peering_connection.main.id}" | |
} | |
### | |
# Module outputs | |
### | |
output "vpc_peering_connection_id" { | |
value = "${aws_vpc_peering_connection.main.id}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I run
terraform plan
, I get the following error:See Terraform issue here.