Skip to content

Commit

Permalink
make sure outputs are always valid (#29)
Browse files Browse the repository at this point in the history
Outputs directly referencing resource IDs that are only conditionally
created are not valid. Use the concat * trick to make sure we always
have a valid value for these outputs.
  • Loading branch information
jbardin authored and antonbabenko committed Nov 16, 2017
1 parent 4098b8a commit 4add490
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ output "database_subnets_cidr_blocks" {

output "database_subnet_group" {
description = "ID of database subnet group"
value = "${aws_db_subnet_group.database.id}"
value = "${element(concat(aws_db_subnet_group.database.*.id, list("")), 0)}"
}

output "elasticache_subnets" {
Expand All @@ -67,7 +67,7 @@ output "elasticache_subnets_cidr_blocks" {

output "elasticache_subnet_group" {
description = "ID of elasticache subnet group"
value = "${aws_elasticache_subnet_group.elasticache.id}"
value = "${element(concat(aws_elasticache_subnet_group.elasticache.*.id, list("")), 0)}"
}

# Route tables
Expand Down Expand Up @@ -99,22 +99,22 @@ output "natgw_ids" {
# Internet Gateway
output "igw_id" {
description = "The ID of the Internet Gateway"
value = "${aws_internet_gateway.this.id}"
value = "${element(concat(aws_internet_gateway.this.*.id, list("")), 0)}"
}

# VPC Endpoints
output "vpc_endpoint_s3_id" {
description = "The ID of VPC endpoint for S3"
value = "${aws_vpc_endpoint.s3.id}"
value = "${element(concat(aws_vpc_endpoint.s3.*.id, list("")), 0)}"
}

output "vpc_endpoint_dynamodb_id" {
description = "The ID of VPC endpoint for DynamoDB"
value = "${aws_vpc_endpoint.dynamodb.id}"
value = "${element(concat(aws_vpc_endpoint.dynamodb.*.id, list("")), 0)}"
}

# VPN Gateway
output "vgw_id" {
description = "The ID of the VPN Gateway"
value = "${aws_vpn_gateway.this.id}"
value = "${element(concat(aws_vpn_gateway.this.*.id, list("")), 0)}"
}

0 comments on commit 4add490

Please sign in to comment.