Skip to content

v1.1.2: export vpc s3 and dynamodb cidr blocks too, change the way the structure is constructed #3

Merged
merged 1 commit into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
- vpc
- add enable_aws_dns to use the AmazonDNS Route53 DNS

* v1.1.1 -- 20200629
* v1.1.1 -- 20210629
- peer
- add output of nacl_info

* v1.1.2 -- 20210702
- routing
- export vpc s3 and dynamodb cidr blocks too, change the way the structure is constructed
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
_module_version = "1.1.1"
_module_version = "1.1.2"
}
6 changes: 4 additions & 2 deletions routing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,7 @@ No modules.
| <a name="output_availability_zone_suffixes"></a> [availability\_zone\_suffixes](#output\_availability\_zone\_suffixes) | VPC Availability zone suffix list (3) |
| <a name="output_private_route_table_ids"></a> [private\_route\_table\_ids](#output\_private\_route\_table\_ids) | Private route table IDs map by availability zone |
| <a name="output_public_route_table_ids"></a> [public\_route\_table\_ids](#output\_public\_route\_table\_ids) | Public route table IDs map by availability zone |
| <a name="output_vpc_endpoint_id_dynamodb"></a> [vpc\_endpoint\_id\_dynamodb](#output\_vpc\_endpoint\_id\_dynamodb) | VPC Endpoint ID for DynamoDB |
| <a name="output_vpc_endpoint_id_s3"></a> [vpc\_endpoint\_id\_s3](#output\_vpc\_endpoint\_id\_s3) | VPC Endpoint ID for S3 |
| <a name="output_vpc_endpoint_dynamodb_cidr_blocks"></a> [vpc\_endpoint\_dynamodb\_cidr\_blocks](#output\_vpc\_endpoint\_dynamodb\_cidr\_blocks) | VPC Endpoint CIDR Blocks for DynamoDB |
| <a name="output_vpc_endpoint_dynamodb_id"></a> [vpc\_endpoint\_dynamodb\_id](#output\_vpc\_endpoint\_dynamodb\_id) | VPC Endpoint ID for DynamoDB |
| <a name="output_vpc_endpoint_s3_cidr_blocks"></a> [vpc\_endpoint\_s3\_cidr\_blocks](#output\_vpc\_endpoint\_s3\_cidr\_blocks) | VPC Endpoint CIDR Blocks for S3 |
| <a name="output_vpc_endpoint_s3_id"></a> [vpc\_endpoint\_s3\_id](#output\_vpc\_endpoint\_s3\_id) | VPC Endpoint ID for S3 |
19 changes: 15 additions & 4 deletions routing/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,23 @@ output "private_route_table_ids" {
value = { for k in local.availability_zones : k => aws_route_table.private[k].id }
}

output "vpc_endpoint_id_s3" {
output "vpc_endpoint_s3_id" {
description = "VPC Endpoint ID for S3"
value = local.vpce_s3
value = lookup(local.vpce_s3, "id", null)
}

output "vpc_endpoint_id_dynamodb" {
output "vpc_endpoint_dynamodb_id" {
description = "VPC Endpoint ID for DynamoDB"
value = local.vpce_dynamodb
value = lookup(local.vpce_dynamodb, "id", null)
}

output "vpc_endpoint_s3_cidr_blocks" {
description = "VPC Endpoint CIDR Blocks for S3"
value = lookup(local.vpce_s3, "cidr_blocks", [])
}

output "vpc_endpoint_dynamodb_cidr_blocks" {
description = "VPC Endpoint CIDR Blocks for DynamoDB"
value = lookup(local.vpce_dynamodb, "cidr_blocks", [])
}

12 changes: 8 additions & 4 deletions routing/vpc-endpoints.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#---

locals {
vpce_s3 = var.enable_vpc_endpoint_s3 ? element(concat(aws_vpc_endpoint.s3[*].id, tolist([""])), 0) : ""
vpce_dynamodb = var.enable_vpc_endpoint_dynamodb ? element(concat(aws_vpc_endpoint.dynamodb[*].id, tolist([""])), 0) : ""
# vpce_s3 = var.enable_vpc_endpoint_s3 ? element(concat(aws_vpc_endpoint.s3[*].id, tolist([""])), 0) : ""
# vpce_dynamodb = var.enable_vpc_endpoint_dynamodb ? element(concat(aws_vpc_endpoint.dynamodb[*].id, tolist([""])), 0) : ""
vpce_s3 = element(concat([for k, v in aws_vpc_endpoint.s3 : v], [{}]), 0)
vpce_dynamodb = element(concat([for k, v in aws_vpc_endpoint.dynamodb : v], [{}]), 0)
}

data "aws_vpc_endpoint_service" "s3" {
Expand All @@ -31,7 +33,8 @@ resource "aws_vpc_endpoint" "s3" {
resource "aws_vpc_endpoint_route_table_association" "private_s3" {
for_each = var.enable_vpc_endpoint_s3 ? local.availability_zones : local.empty
# vpc_endpoint_id = aws_vpc_endpoint.s3[0].id
vpc_endpoint_id = local.vpce_s3
# vpc_endpoint_id = local.vpce_s3
vpc_endpoint_id = lookup(local.vpce_s3, "id", null)
route_table_id = aws_route_table.private[each.key].id
}

Expand All @@ -58,6 +61,7 @@ resource "aws_vpc_endpoint" "dynamodb" {
resource "aws_vpc_endpoint_route_table_association" "private_dynamodb" {
for_each = var.enable_vpc_endpoint_dynamodb ? local.availability_zones : local.empty
# vpc_endpoint_id = aws_vpc_endpoint.dynamodb[0].id
vpc_endpoint_id = local.vpce_dynamodb
# vpc_endpoint_id = local.vpce_dynamodb
vpc_endpoint_id = lookup(local.vpce_dynamodb, "id", null)
route_table_id = aws_route_table.private[each.key].id
}